jQuery:使用delay()和prepend()
在下面的代码中,最后一行不能按照我的方式工作:
$('button.goal').click(function () {
$('div.scorer_away').animate({
width: 'hide',
opacy: 'hide'
}, 'slow')
.delay(2500)
.animate({
width: 'show',
opacy: 'show'
}, 'slow');
$('span.scorer_away').delay(3000).prepend('<img src="chofbauer.png" alt="" />');
我怎样才能让它工作,prepend()函数在3秒后添加新图像(因为2.5秒后,img在容器中前置)被隐藏)?
In the following code the last line doesn't work in my way:
$('button.goal').click(function () {
$('div.scorer_away').animate({
width: 'hide',
opacy: 'hide'
}, 'slow')
.delay(2500)
.animate({
width: 'show',
opacy: 'show'
}, 'slow');
$('span.scorer_away').delay(3000).prepend('<img src="chofbauer.png" alt="" />');
How can I make it work, that the prepend()-function adds the new image AFTER 3 sec (because after 2,5 sec the container, where the img prepends is hidden)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
.delay()
仅适用于 jQueryfx 方法
。.prepend()
不是其中之一。您可以解决它,就像
实际上您必须创建自己的 .queue() 以获得“干净” “ 解决方案。
完成该任务的另一种方法是使用 JavaScript 原生
setTimeout()
。.delay()
only works with jQueryfx methods
..prepend()
is not one of those.You can workaround it like
Actually you would have to create your own .queue() for a "clean" solution.
Another way to accomplish that task is to use javascripts native
setTimeout()
.您可以尝试使用
setTimeout
:You could try using
setTimeout
: