How to Make a Div Invisible
1. Using Display Attribute in CSS
2. Using Visibility Attribute in CSS
Invisible div can be created by setting the display attribute in css to none. In the following example div which has a id named divId will be set to invisible. Important thing here is after hiding, the div stays in the web page but no space is taken from the web page. You can make the div visible whenever needed by setting the display attribute to block.
#divId { display:none; }
Another method of creating Invisible div is to set the visibility attribute in css to hidden. In the following example div which has a id named divId will be set to invisible. Important thing here is after hiding, the div stays in the web page and space will be taken from the web page. So in this situation even though you hide the div, area contained by the div will be shown as blank. You can make the div visible whenever needed by setting the visibility attribute to visible.
#divId { visibility:hidden; }
Creating a Invisible Div using Jquery
This will hide the div without any animation effects on the div.
$('#divId').hide();
This method will animate the div when hiding. You can pass slow,pass or valid number to animate. Value of fast is 200 milliseconds and slow is 600 milliseconds.
$('#divId').hide('slow');
Leave a Reply