I have several pairs of DIVS on my page, and I'm trying to modify some
code such that when the first of a pair is clicked (let's call it
div1), it hides itself and shows div2; if div2 is clicked, it hides
itself and shows div 1. The same would happen for div3 and div4, div5
and div6, etc. The numbers appending "div" will be dynamically
generated and the pairs will be two sequential numbers (though there
may be larger gaps between the sets of pairs).
The code thus far is:
function hidediv(id) {
//safe function to hide an element with a specified id
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById(id).style.display = 'none';
}
else {
if (document.layers) { // Netscape 4
document.id.display = 'none';
}
else { // IE 4
document.all.id.style.display = 'none';
}
}
}
The obviously hides the div that's been clicked, so the problem I'm
having is showing the "next" div. The other function showdiv(), simply
does the reverse. How do I get javascript to find the next or previous
div? Thanks.