< Jquery Tutorial

Jquery hide()

← Previous Next →


The jQuery hide() method is used to hide the selected elements.

Syntax:

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

speed: It is an optional parameter. It specifies the speed of the delay. Its possible vales are slow, fast and milliseconds.

easing: It specifies the easing function to be used for transition.

callback: It is also an optional parameter. It specifies the function to be called after completion of hide() effect.

 

 

Let's take an example to see the jQuery hide effect.

$("#hide").click(function(){
    $("p").hide();
});

$("#show").click(function(){
    $("p").show();
});

 

 

Toggling the elements

jQuery provides methods to toggle the display state of elements between revealed or hidden. If the element is initially displayed, it will be hidden; if hidden, it will be shown.

Syntax
Here is the simple syntax for one of the toggle() methods −

[selector]..toggle([speed][, callback]);

Here is the description of all the parameters −

speed − A string representing one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000).

callback − This optional parameter represents a function to be executed whenever the animation completes; executes once for each element animated against.

Example :

$("button").click(function(){
    $("p").toggle();
});
← Previous Next →