Click here for the code snippet
The code provided seems to have a problem where hello2 and hello3 are not displaying. Is this issue related to the fact that '#id can only be used once'? Making it a class does not seem to work either. How can this be fixed?
Here is the HTML:
<a href="javascript:unhide('menu');">Toggle</a>
<div id="menu" class="hidden">hello</div>
<div id="menu" class="hidden">hello2</div>
<div id="menu" class="hidden">hello3</div>
CSS:
.hidden {
display: none;
}
.unhidden {
display: block;
}
JavaScript:
function unhide(divID) {
var item = document.getElementById(divID);
if (item) {
item.className = (item.className == 'hidden') ? 'unhidden' : 'hidden';
}
}