Sha256: f03f6c859d3b17025d9a3a22281a4b0f83ce7fb401a583867355639b24af347c
Contents?: true
Size: 1.51 KB
Versions: 1
Compression:
Stored size: 1.51 KB
Contents
window.onload=function() { // get tab container var container = document.getElementById("tabContainer"); var tabcon = document.getElementById("tabscontent"); //alert(tabcon.childNodes.item(1)); // set current tab var navitem = document.getElementById("tabHeader_1"); //store which tab we are on var ident = navitem.id.split("_")[1]; //alert(ident); navitem.parentNode.setAttribute("data-current",ident); //set current tab with class of activetabheader navitem.setAttribute("class","tabActiveHeader"); //hide two tab contents we don't need var pages = tabcon.getElementsByTagName("div"); for (var i = 1; i < pages.length; i++) { pages.item(i).style.display="none"; }; //this adds click event to tabs var tabs = container.getElementsByTagName("li"); for (var i = 0; i < tabs.length; i++) { tabs[i].onclick=displayPage; } } // on click of one of tabs function displayPage() { var current = this.parentNode.getAttribute("data-current"); //remove class of activetabheader and hide old contents document.getElementById("tabHeader_" + current).removeAttribute("class"); document.getElementById("tabpage_" + current).style.display="none"; var ident = this.id.split("_")[1]; //add class of activetabheader to new active tab and show contents this.setAttribute("class","tabActiveHeader"); document.getElementById("tabpage_" + ident).style.display="block"; this.parentNode.setAttribute("data-current",ident); }
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
multiinsert-0.0.1 | app/assets/javascripts/tabs_old.js |