jQuery hide and show

jQuery hide() and show()


With jQuery, you can hide and display HTML elements using the hide() and show() methods:

Instance

 
Run the program and try it out

Grammar:


$(selector).hide(speed,callback); 

$(selector).show(speed,callback);

The optional speed parameter specifies the speed of the hide/show, which can take the following values: "slow", "fast" or milliseconds.

The optional callback parameter is the name of the function that is executed after the display is hidden or displayed.

The following example demonstrates the hide() method with the speed parameter:

 
Run the program and try it out

jQuery toggle()


With jQuery, you can toggle the hide() and show() methods with the toggle() method.

Show hidden elements and hide the displayed elements:

 
Run the program and try it out

Grammar:


$(selector).toggle(speed,callback);

The optional speed parameter specifies the speed of the hide/show, which can take the following values: "slow", "fast" or milliseconds.

The optional callback parameter is the name of the function that is executed after the toggle() method completes.


Last Updated: 2018-11-24 14:03:46 By Akshay

SHARE THIS

share_facebook share_twitter share_google_plus

Please Comment Here :