If you're injecting CSS, here's a cross-browser (not thoroughly tested, though) way to do it:
I used the above code to hide elements in a script that was located in the <head> tag (at which point no elements are programmatically accessible.)Code:if (document.createStyleSheet) { var style = document.createStyleSheet(); style.addRule("div.content", "display: none;"); } else { var head = document.getElementsByTagName("head")[0]; if (head) { var style = document.createElement("style"); style.setAttribute("type", "text/css"); style.appendChild(document.createTextNode("div.content { display: none; }")); head.appendChild(style); } }




Reply With Quote