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:

// ====Start of the code====

1) To hide html elements, use the following:
jQuery(“#id-to-hide”).click(function(){
jQuery(“p”).hide();
});

2) To show html elements, use the following:
jQuery(“#id-to-show”).click(function(){
jQuery(“p”).show();
});

3) To toggle/switch html elements, use the following:
jQuery(“#id-to-toggle”).click(function(){
jQuery(“p”).toggle();
});

// ====End of the code====

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s