Hi,
I have a span, and in that I have many DIVs.
I want to enable one div at a time, on user click.
for this, i have written a JS function that changes display option for the divs.
the code is :
Code:
function enableGallery(name)
{
var children=document.getElementById('gallery').childNodes;
for (var i=0;i<children.length;i++)
{
elem = children[i];
if (elem != null)
{
elem.style.display='none';
}
else
{
alert('elem is null');
}
}
var my=document.getElementById(name);
my.style.display='block';
}
my span looks like
Code:
<span id="gallery" style="display:none;background-color: black; height: 100%; color: white; padding: 10px;">
<div id="simplegallery1" name = "simplegallery1" style="display:none;background-color: black;"> </div>
<div id="simplegallery2" name = "simplegallery2" style="display:none;background-color: black;"> </div>
<div id="simplegallery3" name = "simplegallery3" style="display:none;background-color: black;"> </div>
</span>
the JS function works well in IE, but in FF, it says it has 7 children elements, but then iterates only one time.
Any suggestion how to write this function in a browser independent manner?
Thanks in anticipation
Saurabh
<link drop removed>
Last edited by chrishirst; 04-04-2010 at 04:30 PM..
|