Saturday, 26 March 2016

How to use jQuery effects - hide, show and toggle ?


jQuery - Hide / Show

Hide and show HTML elements.

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

SYNTAX
$(selector).hide(speed,callback);
$(selector).show(speed,callback);
speed - specifies the speed of the hiding / showing. Possible values: "slow", "fast", or milliseconds.
callback - function to be executed after the hide() or show() method completes.

Example
$("button").click(function(){
 $("p").hide(1000);
});


jQuery - toggle()

Toggle between the hide() and show() methods.

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

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

No comments:

Post a Comment

Note: only a member of this blog may post a comment.