i'm using a simple couple scripts from http://www.theimposter.org/ to show and hide blocks of information when you click on a 'parent' element, so to speak. not in the DOM sense or anything, just a description.
anyway, before i've confused everybody thoroughly, here's what i've got:
the above section shows and hides the elements. that all works great. no problems.
this is the block of code that is supposed to make sure all the elements you can show/hide are hidden by default. now, the script came to me using that getElementsByTagName method which works great, but isn't very sensical to me. as you can see, i had to use <h6> as it is the only element i could think of that isn't used for some other purpose. i.e. <divs> or <spans> are out because i use them other places on the site and of course don't want them hidden!
now, i figured it would be easy enough to modify that script to check for all elements of a certain tag name, and then within that for loop check for ones with a certain class attribute defined.
rather than post what i tried, (partly because i don't remember exactly, and i'm not very skilled with JS), i was wondering if somebody could help me with the solution to this. i know that it's got to be painfully simple.
thanks.
anyway, before i've confused everybody thoroughly, here's what i've got:
Code:
function expand(q) { if (document.getElementById(q).style.display == 'none') { document.getElementById(q).style.display = 'block'; } else { document.getElementById(q).style.display = 'none'; } }
Code:
function hideAll() { var Nodes = document.getElementsByTagName('h6') var max = Nodes.length for(var i = 0;i < max;i++) { var nodeObj = Nodes.item(i) nodeObj.style.display = 'none'; } }
now, i figured it would be easy enough to modify that script to check for all elements of a certain tag name, and then within that for loop check for ones with a certain class attribute defined.
rather than post what i tried, (partly because i don't remember exactly, and i'm not very skilled with JS), i was wondering if somebody could help me with the solution to this. i know that it's got to be painfully simple.
thanks.

Comment