Showing and hiding

By default, jQuery's show(), hide(), and toggle() methods show or hide the selected element by manipulating its display style property. This is an instantaneous effect and does not constitute an animation.

Usually these methods do not take any arguments, but we can trigger an animation by supplying an additional argument which represents either the duration, or the easing of the animation. We can also add a callback function in keeping with the animation methods we have looked at so far.

The methods can take the following format:

jQuery(elements).show(duration, [easing], [callback]);
jQuery(elements).hide(duration, [easing], [callback]);

These animations are a step-up in complexity from simple fading because instead of just animating ...

Get jQuery 1.4 Animation Techniques Beginner's Guide 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.