JQuery - Hide And Show With Toggle Example

In this tutorial i will discuss about jQuery toggle(). I will showyou how we can use jQuery toggle() with html dom. We can also toggle between hiding and showing an element with the toggle() method.

Let's see the example of jquery toggle function. Here shown doms are hidden and hidden doms are shown:

Example

$("button").click(function(){
  $("p").toggle();
});

 

Syntax:

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

 

The optional first speed parameter can take the following attributes: "slow", "fast", or milliseconds.

The optional second callback parameter is a function to be executed after toggle() completes.

Example

 

Hope this jquery toggle example tutorial will help you.

 

#jquery #jquery-toggle