asmith Posted June 8, 2008 Share Posted June 8, 2008 hey guys i'm using such tabs in my page : <div id="titles"> <div class="on"><span>test1</span></div> <div class="off"><span>test2</span></div> </div> <div id="test1" class="show"> here goes the first paraghraph </div> <div id="Monet" class="hide"> second one </div> the java code : onload = function() { var e, i = 0; while (e = document.getElementById('titles').getElementsByTagName ('DIV') [i++]) { if (e.className == 'on' || e.className == 'off') { e.onclick = function () { var getEls = document.getElementsByTagName('DIV'); for (var z=0; z<getEls.length; z++) { getEls[z].className=getEls[z].className.replace('show', 'hide'); getEls[z].className=getEls[z].className.replace('on', 'off'); } this.className = 'on'; var max = this.getAttribute('title'); document.getElementById(max).className = "show"; } } } } all the tab contents are in the page, so it is simple. i have this JS typing effect : http://www.scintilla.utwente.nl/frederiek I want to combine these 2 codes, so that when i click on a tab , it shows its content with like someone's typing them , and stop when it is finish( no repeat) , can someone help me with that ? Quote Link to comment Share on other sites More sharing options...
haku Posted June 8, 2008 Share Posted June 8, 2008 I won't write the code, but I'll point you in a direction you could take. You will basically want to grab all the links that open and close the tabs into an array, and run a loop that sets an onclick listeners to each of the links. The onclick listener will call a function when the links are clicked. Within that function, you want to change the visibility of the necessary tabs, and call the function that activates the typing script. You will probably have to build a new variable into the the typing function to tell it which content it should be typing out to the screen. Quote Link to comment Share on other sites More sharing options...
asmith Posted June 9, 2008 Author Share Posted June 9, 2008 I did it once, but the text inside the paragraph didn't moved. I'll try more. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.