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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.