javascript - Get the time show animation how much duration is currntly running -


in jquery use following code:

  j=-(i)   if(j%2==1)   {     $("#caption1").hide();     $("#caption1").fadein(1000);     $('#main_div').hide();     $('#main_div').show(5000);   }    }  if(i%2==0)  {     $("#caption1").hide();     $("#caption1").fadein(1000);     $('#main_div').hide();     $('#main_div').show(5000);  } 

while show animation want duration of animation completed?

for example:

i set show animation 5secs.

show animation started.

2 secs animation completed[ 3secs remaining]

in case need completed duration[2secs] on button click??

mark down time when animation started:

var animationstarted = new date(); $('#main_div').show(5000); .... 

when need show how time has passed, take current time , subtract time saved in previous step.

var = new date(); var elapsed = ( now.gettime() - animationstarted.gettime() ) / 1000; 

demo: http://jsfiddle.net/nzgu6/


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -