jQuery Show/Hide Effects

jQuery show/hide Effects

With jQuery, you can use jQuery show/hide effect an HTML elements using the functions show() and hide(). The hide() can be used to hide some HTML element when some event occurs while show() can be used to display the hidden element.

Syntax

The syntax contains the selector to access HTML element and a show function that contains two optional parameters. The first parameter can be used to provide the speed of the effect in milliseconds.

The show() reverse the effect of hide() and display the element hidden by hide(). The hide() applies the display:none CSS to the HTML element when use the jquery function while show() applies the display:block CSS.

Check the example given below to find out the changes effects.

Test it Live

Output

The content to display jQuery show/hide function effect.

Click the hide button given above to see the hide effect of jQuery. Now, if you want to show the hidden element, you can click the show button given above which reverses the effect of hide function.

Use the jQuery selectors to select, access the HTML element and apply the required operation.

jQuery toggle() for both jQuery show/hide effects

If you want to perform both the hide and show effects using the jQuery and don’t want to use the hide and show function. A single toggle() is an alternative you can use to perform both jQuery show/hide effect of jQuery. With only that single jQuery function you can perform both the operations.

The function is easy to use and operation is same as the jQuery show/hide function.

Test it Live

Output

Click the below button to toggle this content.


Click the toggle button given above to see the effect of the jQuery toggle(). You can notice the effect of both hide and show function with just a single toggle().

Developers use both hide() and show() while developing an application. However, if you want to show the hidden HTML element, you need to only use the show() which applies the display: block CSS to the HTML element.

The toggle() can be used only when you want to first hide the element and then show the element and vice versa.

You must also read.

THE ULTIMATE TOOLKIT

Get FREE Access to Toolkit and Resources that we are using in Tutorialdeep that Every Professional Should Have! in one handy PDF.

Get the PDF

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

ULTIMATE TOOLKIT Free eBookX

Get FREE Access to Toolkit and Resources that we are using in Tutorialdeep that Every Professional Should Have! in one handy PDF.

Download Link Will be Send to Your Email id

Download Link Will be Send to Your Email id