Sent by Martin Sammtleben on 23 September 2002 03:03
Hi listees,
I have been experimenting with the "ON/OFF" switch on Jeffrey Z's
site which he used to hide/display subtopics. It's a very simple
script in the form of:
// toggle visibility
function toggle( targetId ){
if (document.getElementById){
target = document.getElementById( targetId );
if (target.style.display == "none"){
target.style.display = "";
} else {
target.style.display = "none";
}
}
}
in the body follows the content enclosed in a div preceded by the trigger:
Recent <a href="#" onclick="toggle('essentials');return false;">Essentials</a>
<div id="essentials" style="display:none">
(content... )
</div>
O.K. that works very well for this single ID but what if I wanted to
toggle like 5 or more elements simultaneously? Can I do that with
classes too?
Being basically a JavaScript illiterate, I tried substituting
"document.getElementByclassName" but it didn't work - any chance to
pull it off?
I would very much appreciate any help or hints :-)
Cheers Martin