Jump to content

typing effect mix with tab


asmith

Recommended Posts

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 ?

 

 

Link to comment
https://forums.phpfreaks.com/topic/109230-typing-effect-mix-with-tab/
Share on other sites

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.