All TalkersCode Topics

Follow TalkersCode On Social Media

devloprr.com - A Social Media Network for developers Join Now ➔

jQuery Hide and Show

With jQuery Hide and Show you can hide and show the elements by using hide() and show() methods.


Syntax of hide()

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


Syntax of show()

$(selector).show(speed,callback);


Code Explanation

  • It takes speed parameter to define what speed the hide and show effect takes place it takes value in milliseconds.
  • It takes callback as an optional parameter you can give function that is executed after the completion of effect.

Example of hide()

$("button").click(function(){
  $("div").hide(500);
});


Example of show()

$("button").click(function(){
  $("div").show(500);
});


jQuery toggle()

jQuery toggle() effect is used to toggle between hide() and show() automatically


Syntax of hide()

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


Example of toggle()

$("button").click(function(){
  $("div").toggle();
});
❮ PreviousNext ❯