Sunday, May 16, 2010

Show and Hide div using Jquery

Hey with just a simple line of code you can show and hide a div...

Before Jquery we write our code something like :

For hiding a div : document.getElementById(id).style.display = 'none';
For Showing a div: document.getElementById(id).style.display = 'block';

and now with the cool feature of JQuery :

For hiding a div : $("#divResult").hide();
For Showing a div: $("#divResult").show();

And also we can play around with this
like

$("#divResult").show(2000);

It will slowly display the div in 2 seconds.....

And for hiding

$("#divResult").hide("slow");

Its hides your div slowly..


Cheers...