So, I have a nav element with an unorder list that I use as tabs. There are three, you click one and it shows a div in the website. However, I want it so that if you click another, it will hide the one currently being shown, and then show the one you clicked. But I can't seem to get it right. Here is the function I have:
function display(action, id)
{
if (action == 'show')
{
document.getElementById("page"+id).style.display = "block";
document.getElementById("link"+id).href= "javascript:display('hide', "+id+")";
}
if (action == 'hide')
{
document.getElementById("page"+id).style.display = "none";
document.getElementById("link"+id).href= "javascript:display('show', "+id+")";
}
}
</script>
I tried to do something like
document.getElementById("page"+id+1).style.display = "none";
I thought that it would change the display style to none of the div with an id one more than the current, but instead it does nothing. What would I add to this to have it hide all currently open tabs?