Forum Moderators: open
document.write('<style>.collapsed-div .article {display:none;}</style>'); document.getElementsByClassName("collapsed-div").getElementsByClassName("article").style.display = "none";
var i, j, k, n, articles,
collapsed-divs = document.getElementsByClassName("collapsed-div");
for (i = 0, n = collapsed-divs.length; i < n; i++) {
articles = collapsed-divs[i].getElementsByClassName("article");
for (j = 0, k = articles.length; j < k; j++) {
articles[j].style.display = "none";
}
}
for (i=0; i<document.styleSheets.length; i++){
var mySheet = document.styleSheets[i];
var myRules = mySheet.cssRules? mySheet.cssRules: mySheet.rules
for (j=0; j<myRules.length; j++) {
if (myRules[j].selectorText == '.collapsed-div') {
myRules[j].style.display = 'none';
} // endif .collapsed-div
} // end for j
} // end for i
JavaScript doesn't provide a way to set the style on a collection of elements using a simple syntax
Another approach you might consider would be to use JavaScript to attach a class to the body element. For example, you might attach a class "jsEnabled". Then in your CSS, you could do:
.jsEnabled .collapsed-div .article {display:none;}
document.getElementsByTagName('body')[0].className = 'jsEnabled';*