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> ...

Get jQuery 2.0 Development Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.