2012-01-10 173 views
0

你好家伙我试图做一个简单的动画,但有些延迟,但它不工作,请给我一只手。这里是代码jquery延迟不起作用

$(document).ready(function() { 
    $('.detailsholder').hide() 
    $(".detailsholder").animate({"top": '-520px'},1) 
    $('.detailsholder').hide() 
    $('.detailsholder').fadeIn(500) 
    $('.detailsholder').delay(5000).animate({'top': "-260px",'easing': "easeInElastic"}, 400).delay(5000).('.detailsholder').animate({'top': "0px",'easing': "easeInElastic"},400); 
}); 
+4

你的分号在哪里? – 2012-01-10 15:12:29

+5

你应该链接你的jQuery语句。 – 2012-01-10 15:14:29

+2

:(这是JavaScript的知识的jQuery的不良影响的例子 – Harmen 2012-01-10 15:51:58

回答

0
$(function(){ 
    $('.detailsholder').hide().animate({"top": '-520px'},1).fadeIn(500).delay(5000).animate({'top': "-260px",'easing': "easeInElastic"},400).delay(5000).animate({'top': "0px",'easing': "easeInElastic"},400); 
}); 
+0

此剂量不工作 – 2012-01-10 15:50:17

0

我假设你希望动画结束后,在这种情况下,你应该把它放到回调每个delay()发生。就目前而言,延迟将在动画发生时运行。

此外,作为评论说,你真的应该链中的语句并添加分号你行结束。

+0

是的,我想每个动画 – 2012-01-10 15:50:34

0

也有一些是错误代码中的第6行(我分裂该行分成若干这里更好的阅读:

$('.detailsholder') 
.delay(5000) 
.animate({'top': "-260px",'easing': "easeInElastic"}, 400) 
.delay(5000) 
.('.detailsholder') // The method is missing here! 
.animate({'top': "0px",'easing': "easeInElastic"},400); 

注意:您也应连锁jQuery代码并把分号每个命令后。 。

+0

我尝试这一个我不工作 – 2012-01-10 15:49:36

+0

后延迟“的方法在这里失踪!”? – Stefan 2012-01-10 16:17:34

+0

这不工作,因为它是你的代码吗?看看你在忘记该方法的注释线。 – 2012-01-10 16:40:55

0

这里有一个solution为你;

$('.detailsholder') 
    .hide() 
    .css('top', '200px') 
    .fadeIn(500) 
    .delay(2000) 
    .animate({'top': "100px", 'easing': "easeInElastic"}, 400) 
    .delay(2000) 
    .animate({'top': "0px", 'easing': "easeInElastic"}, 400); 

您可能会考虑使用ID而不是类,因为您的动画看起来很独特。

享受! :)