0

我想在这两条消息之间创建一个延迟:

$('#submit-account').html(animation + 'Submitting Data')
$('#submit-account').html(animation + 'Validating Email')

我试过这个:

var ani = "<i class='icon-spin'></i> "
$('#submit-account').html(ani + 'Wait').delay(5000).fadeIn();
$('#submit-account').html(ani + 'Done').delay(10000).fadeIn();

但是没有延迟,为什么呢?

4

4 回答 4

3

我认为这个问题是因为delay()仅延迟队列中的项目(jQuery 仅自动排队动画)。所以尝试修改fade函数fadeIn(0),jQuery会将其解释为动画,现在延迟应该可以工作了。

于 2013-10-18T09:53:27.693 回答
1

maybe you need to link JQuery 1.9.1, this is working: jsFiddle is here

<script src="http://code.jquery.com/jquery-1.9.1.js"></script>

and note that delay() method is for delaying between queued jQuery effects.

take a look at this jsFiddle


reference


于 2013-10-18T09:55:58.077 回答
1

确保#submit-account 已经隐藏。

而不是你的代码,你可以试试这个

$('#submit-account').html(ani + "Wait").fadeIn(5000);


 $('#submit-account').html(ani + "Done").fadeIn(5000);

这将控制淡入淡出效果的速度。或者,如果您希望 div 在一段时间后淡入,您可以使用该setTimeOut()功能。

希望对你有帮助

于 2013-10-18T09:53:24.170 回答
0

I'm not sure if i'm understanding it precisely or correct but there's a Default Built in JavaScript setTimeOut(); Function.

For more info :How to wait 5 seconds with jQuery?

于 2013-10-18T09:57:41.657 回答