jQuery : hide(), show() and toggle() Methods

You can use the below common jQuery methods which are used to hide, show and toggle HTML elements:

Please find the sample code with examples below:
1) To hide html elements, use the following code snippet:

jQuery(“#id-to-hide”).click(function(){
jQuery(“p”).hide();
});

 

2) To show html elements, use the following code snippet:

jQuery(“#id-to-show”).click(function(){
jQuery(“p”).show();
});

 

3) To toggle/switch html elements, use the following code snippet:

jQuery(“#id-to-toggle”).click(function(){
jQuery(“p”).toggle();
});

 

Leave a Reply