javascript - Need this function to run/rerun depending on which tab I have selected -


i have created page calls specific php page depending on tab click on. right work great on first tab fails on second because finds first 'nav' on first tab , counts not other tabs. how run on page load , when click next menu tab?

window.onload=function() {     var aobj=document.getelementbyid('nav').getelementsbytagname('a');     var i=aobj.length;      while(i--) {         aobj[i].count = i;        aobj[i].onclick=function() {return showhide(this);};        showhide(aobj[i]);     } };  function showhide(obj) {     var adiv=document.getelementbyid('basecontent').getelementsbytagname('div');     if (typeof showhide.counter == 'undefined' ) { // create static variable         showhide.counter = 0; // 1st div     }     adiv[showhide.counter].style.display = 'none'; // close open div      adiv[obj.count].style.display = 'block'; // open requested div     showhide.counter = obj.count; // save div number open     return false; // prevent link's natural event firing } 


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -