Book Image

jQuery 2.0 Development Cookbook

By : Leon Revill
Book Image

jQuery 2.0 Development Cookbook

By: Leon Revill

Overview of this book

Table of Contents (17 chapters)
jQuery 2.0 Development Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Hiding and showing elements


jQuery includes functions that will allow you to simply hide and show elements, although you can use these functions in conjunction with other effects.

Getting ready

Create a new HTML file named recipe-2.html and save it to the same folder as your jQuery library.

How to do it…

Understand how you can use jQuery to easily hide and show elements in the DOM by performing the following steps:

  1. In recipe-2.html, add the following HTML code. Ensure that the reference to the jQuery library is pointing to the correct location and filename of your downloaded version.

    <!DOCTYPE html>
    <html>
    <head>
      <title>Chapter 4 :: JQuery Effects :: Recipe 2</title>
      <script src="jquery.min.js"></script>
      <script src="recipe-2.js"></script>
    </head>
    <body>
    <button class="show">Show</button>
    <button class="hide">Hide</button>
    <p class="text">Hiding and showing HTML elements with jQuery is so easy...