jQuery animate()无法控制地随机滑动

时间:2012-02-29 22:18:37

标签: jquery jquery-animate

我一直在制作一个脚本来滑动抽屉打开和关闭以显示更多隐藏内容。您可以在此处查看正在运行的工作脚本: http://igs.link-networkonline.com/campaign-landing-page/

这是我的错误...虽然有几次“抽屉”会有些不受控制地反弹(打开和关闭),但我必须点击才能阻止它。它似乎随机发生......

有没有其他人曾经.hover()遇到过这类事情?我看到有些人发布了关于不使用.mouseover但没有使用.hover()

的内容

这是我的代码:

   $(document).ready(function () {

    $(".first").hover(function() {
        $(".first").animate({'height': '257px', 'top': "-183px"});
        $("img.button1").animate({'top': "-205px"});
        $('img.button1').attr('src','<?php bloginfo('template_directory'); ?>/images/downarrow.png');
        $("body").animate({'padding-bottom': '-300px'});
    }, function() {
        $(".first").animate({'height': '75px', 'top': "-1px", 'overflow': "hidden"});
        $("img.button1").animate({'top': "-25px"});
        $('img.button1').attr('src','<?php bloginfo('template_directory'); ?>/images/bluebutton.png');
    });
   $(".second").hover(function() {
        $(".second").animate({'height': '255px', 'top': "-181px"});
        $("img.button2").animate({'top': "-205px"});
        $('img.button2').attr('src','<?php bloginfo('template_directory'); ?>/images/downarrow.png');
    }, function() {
        $(".second").animate({'height': '75px', 'top': "-1px"});
        $("img.button2").animate({'top': "-25px"});
        $('img.button2').attr('src','<?php bloginfo('template_directory'); ?>/images/bluebutton.png');
    });
    $(".third").hover(function() {
        $(".third").animate({'height': '230px', 'top': "-156px"});
        $("img.button3").animate({'top': "-180px"});
        $('img.button3').attr('src','<?php bloginfo('template_directory'); ?>/images/downarrow.png');
    }, function() {
        $(".third").animate({'height': '75px', 'top': "-1px"});
        $("img.button3").animate({'top': "-25px"});
        $('img.button3').attr('src','<?php bloginfo('template_directory'); ?>/images/bluebutton.png');
    });

}); 

1 个答案:

答案 0 :(得分:4)

您想使用stop() http://api.jquery.com/stop/

相关问题