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