1function ToggleVisibility(divClass)
2{
3 var els = document.getElementsByClassName(divClass);
4 for(var i = 0; i < els.length; i++)
5 {
6 els[i].style.visibility = els[i].style.visibility == "hidden" ? "visible" : "hidden";
7 }
8}
9
1<div class="hide1">One</div>
2<div class="hide2">Two</div>
3
4<a href="#" onclick="ToggleVisibility('hide1'); return false;">One</a>
5<a href="#" onclick="ToggleVisibility('hide2'); return false;">Two</a>
6<a href="#" onclick="ToggleVisibility('nosuchclass'); return false;">No hide</a>
7