$(document).ready(function(){ //get all tab elements var tabDoc = document.getElementById("multi_tab_module"); try { var tabs = tabDoc.getElementsByTagName("li"); var tabNum = tabs.length; } catch(error) { // } function removeSelected() { for (var i=0;i< tabNum;i++) { $(tabs[i]).removeClass("tab-selected"); } for (var a=1;a< tabNum+1;a++) { $("#tab-content"+a).hide(); } } $("#tab1").click(function(e) { removeSelected(); $("#tab1").addClass("tab-selected"); $("#tab-content1").show(); return false; }); $("#tab2").click(function(e) { removeSelected(); $("#tab2").addClass("tab-selected"); $("#tab-content2").show(); return false; }); $("#tab3").click(function(e) { removeSelected(); $("#tab3").addClass("tab-selected"); $("#tab-content3").show(); return false; }); $("#tab4").click(function(e) { removeSelected(); $("#tab4").addClass("tab-selected"); $("#tab-content4").show(); return false; }); $("#tab5").click(function(e) { removeSelected(); $("#tab5").addClass("tab-selected"); $("#tab-content5").show(); return false; }); //hover states $("#tab1").hover(function(e) { $("#tab1").addClass("tab-hover"); }, function(){ $("#tab1").removeClass("tab-hover"); }); $("#tab2").hover(function(e) { $("#tab2").addClass("tab-hover"); }, function(){ $("#tab2").removeClass("tab-hover"); }); $("#tab3").hover(function(e) { $("#tab3").addClass("tab-hover"); }, function(){ $("#tab3").removeClass("tab-hover"); }); $("#tab4").hover(function(e) { $("#tab4").addClass("tab-hover"); }, function(){ $("#tab4").removeClass("tab-hover"); }); $("#tab5").hover(function(e) { $("#tab5").addClass("tab-hover"); }, function(){ $("#tab5").removeClass("tab-hover"); }); });