After researching this issue for a couple of hours, I found that one of the most efficient ways to toggle a page element\'s display (in HTML) is to do something like:
<
Yes, it resets the element's display property to the default by blanking out the inline "display: none", causing the element to fall back on its display property as defined by the page's ranking CSS rules.
For example, here's a A Upon loading your page, the All of thse have the same effect: adding an inline If you wish to show the element again, any of these would work: These remove the Since the inline style no longer specifies a For giggles, here's the Google query I used for verification of my answer: ...and a couple of links where this is mentioned: http://jszen.blogspot.com/2004/07/table-rowsrevealed.html http://www.harrymaugans.com/2007/03/05/how-to-create-a-collapsible-div-with-javascript-and-css/
(not in the article, but in the comments section)
display:block by default. In our style sheet, suppose we specify that your table:
div#myElement
{
display:table;
}
table. If you want to hide this // JavaScript:
document.getElementById("myElement").style.display = 'none';
// jQuery:
$("#myElement").toggle(); // if currently visible
$("#myElement").hide();
$("#myElement").css({"display":"none"});
style property to your
// JavaScript:
document.getElementById("myElement").style.display = "";
// jQuery:
$("#myElement").toggle(); // if currently hidden
$("#myElement").show();
$("#myElement").css({"display":""});
display CSS property from the inline style property:
display, the table, since that's what we put in the style sheet. The block because our CSS overrode that default setting; blanking out the inline display property does not negate the rules in our style sheets.
javascript style display empty string default