I'm somewhat new to javascript/DHTML, and this problem has been
plaguing me. I have made an 'array' of <div> tags within my html
document like so:
<div id="menu"> menu1 </div>
<div id="menu"> menu2 </div>
<div id="menu"> menu3 </div>
<div id="menu"> menu4 </div>
<span onclick="showOr Hide('menu[0]')"> show/hide menu1 </span>
<span onclick="showOr Hide('mennu[1])"> show/hide menu2 </span>
I want to be able to show/hide a menu by clicking on the specified
area...
in IE6 this is easily done with this javascript:
function showOrHide(id){
var myObject = eval(id);
if( myObject.style. display == 'none') myObject.style. display =
'block';
else myObject.style. display = 'none';
}
this allows me to hide/show the menus as needed (my code is a little
more complicated, including an 'API' to make my page 'work' on multiple
browsers, but this is the basic idea in essence)
what is the correct way to reference the <div> array in firefox?? I've
tried multiple ways such as document.getEle mentById(), etc... but I
just can't figure it out, is it even possible? are these element
'arrays' proprietary to IE? I know I'll feel really lame when I find
out, but i've searched for hours and haven't found anything close to an
answer.