Sunday, 15 September 2013

jquery - Javascript add delay to animate -



jquery - Javascript add delay to animate -

i've been trying add together delay 1 of javascript animations , error says "object doesn't back upwards property or method 'delay'". i'm testing on ie 8 compatibility way.

below mentioned code i've tried.

from

$('a',$(this)).stop().animate({'margintop':'200'},1000);

to

$('a',$(this)).stop().delay(1000).animate({'margintop':'200'},1000);

here jsfiddle.

best regards,

vernon

there 2 main problems on fiddle:

1) animation code set before jquery. thats why typeerror: $ not defined in console. include jquery in <head> before code , without wrapping function:

<head> .... <script> /* jquery here */ </script> <script> $(function() { /* code here */ }); </script> .... </head>

2) using old jquery version1.3.2 having no delay function. that's why typeerror: undefined not function when calling .delay(). either utilize newer version of jquery (>= 1.4.3) or define delay-function yourself:

$(function() { // original $.fn.delay copied jquery v1.4.3 source: jquery.fn.delay = function( time, type ) { time = jquery.fx ? jquery.fx.speeds[time] || time : time; type = type || "fx"; homecoming this.queue( type, function() { var elem = this; settimeout(function() { jquery.dequeue( elem, type ); }, time ); }); }; /* code here works .delay() */ });

updated fiddle here delay of 1500 inserted.

javascript jquery animation jquery-animate delay

No comments:

Post a Comment