johnmac81
05-22-2012, 11:43 PM
Hi everyone. I am a new comer to Javascript but love it so far. I just seem to keep hitting little walls like this one. It is a tabbed menu. I cannot seem to get the old title menu to return to white when you float over the next menu title. Also, the sub menu is not appearing under the title menu. Any advice would be helpful. I am convinced and hopeful it is something simple. Here is my code:
window.onload = setTabs();
var currentTab = null;
var maxZ = 1;
var tabList;
function setTabs(){
var menuTabs = new Array();
var allElems = document.getElementsByTagName("*");
for(var i = 0; i < allElems.length; i++){
if(allElems[i].className == "tab") menuTabs.push(allElems[i]);
}
for (var i = 0; i < menuTabs.length; i++){
menuTabs[i].onclick = showTab;
}
}
function showTab(){
currentTab.style.backgroundcolor = "white";
tabList = this.getElementsByTagName("ul")[0];
tabList.style.zIndex = maxZ;
currentTab = this;
currentTab.style.backgroundcolor = "rgb(221, 221, 255)";
}
window.onload = setTabs();
var currentTab = null;
var maxZ = 1;
var tabList;
function setTabs(){
var menuTabs = new Array();
var allElems = document.getElementsByTagName("*");
for(var i = 0; i < allElems.length; i++){
if(allElems[i].className == "tab") menuTabs.push(allElems[i]);
}
for (var i = 0; i < menuTabs.length; i++){
menuTabs[i].onclick = showTab;
}
}
function showTab(){
currentTab.style.backgroundcolor = "white";
tabList = this.getElementsByTagName("ul")[0];
tabList.style.zIndex = maxZ;
currentTab = this;
currentTab.style.backgroundcolor = "rgb(221, 221, 255)";
}