/ Published in: HTML
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<ul id="tabbed_sub"> </ul> <script type="text/javascript"> function setLink(i) { a[i].onclick = function () { div[i].style.display = "block"; for(var j = 0; j < div.length; j++) { if (i != j) { div[j].style.display = "none"; } } return false; } } function initTabs() { var tabs = document.getElementById("tabbed_sub"); // put in id for tabbed list here var links = tabs.getElementsByTagName("a"); div = []; a = []; //Initialize tabs for (var i = 0; i < links.length; i++) { div[i] = document.getElementById(links[i].href.substr(links[i].href.indexOf("#") + 1)); if (i != 0) { div[i].style.display="none"; } else { div[i].style.display="block"; } a[i] = links[i]; setLink(i) } } var W3CDOM = document.createElement && document.getElementsByTagName; if(W3CDOM && document.getElementById("tabbed_sub")) { // check W3CDOM compatibility initTabs(); } </script>