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

Toggling effects


Many of the jQuery effects have opposing functions, such as hide() and show() and fadeIn() and fadeOut(). So far, the recipes in this chapter have handled each of these functions separately; for example, one button to show and another to hide. For some of these functions, jQuery provides us with the ability to be able to toggle these opposing effects. This is beneficial because we do not need to deal with each case separately or decide which of the two we need to use. This recipe will look at the toggle functions and show you how they can be used.

Getting ready

In your favorite text editor or IDE, create a blank HTML file named recipe-4.html and save it in the same directory as your jQuery library.

How to do it…

  1. Add the following HTML code to recipe-4.html to create a basic web page:

    <!DOCTYPE html>
    <html>
    <head>
      <script src="jquery.min.js"></script>
      <script src="recipe-4.js"></script>
      <title>Chapter 4 :: JQuery Effects :...