hide()

A Sniper method to hide elements

Typical syntax:

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

Parameters are optional:

  • delay - the amout of time in milliseconds to wait before hiding the element

  • callback - A callback function is executed after the current effect is finished.

$("#mydiv").hide();  //this will hide the selected element

Hide with delay

$("#mydiv").hide(3000);  //this will wait for 3 secs before hiding the element

Hide with a callback function

$("button").click(function(){
  $("p").hide(5000, function(){
    alert("The paragraph is now hidden - after waiting for 5sec");
  });
});

Hide multiple elements

$("ul li*").hide(); //this will hide all the list items in the ul

Last updated