I have the following code on my site ....
At the moment, when the "Test 1" button is pressed, the animation begins. After that, when you click "Test 2" or "Test 3", the animation does not restart ...
How to restart the animation when any of the links is clicked?
And is it possible to have Fade out and Fade In, after the link has been clicked?
HTML markup:
<div id="anim"></div> </br> </br> <li id="item1"><span></span><a href="#">Test 1</a></li> <li id="item2"><span></span><a href="#">Test 2</a></li> <li id="item3"><span></span><a href="#">Test 3</a></li>
CSS
#anim { width: 14px; height: 14px; background-image: url(http://mail.google.com/mail/im/emotisprites/wink2.png); background-repeat: no-repeat; }
JavaScript:
var scrollUp = (function () { var timerId, height, times ,i = 0 , element; return { stop : function(){ clearInterval( timerId ); }, init :function( h, t, el ){ height = h; times = t; element =el ; }, start : function ( ) { timerId = setInterval(function () { if (i > times)
Here's the script: http://jsfiddle.net/ctF4t/3/
source share