jquery .stop() not working

时间秒杀一切 提交于 2019-12-01 18:08:16

I'm not the biggest animation genius, but I bet it has to do with the fact that you're rebuilding the jQuery object in each handler. Try this:

$(function(){
    var children = $('#menubar .breadcrumbs').children('li + li');
    children.hide();

    $("#menubar .breadcrumbs").hover(function() {
        children.stop().show("slide", {}, 'slow');
    }, function() {
        children.stop().hide("slide", {}, 'slow');
    });
});

edit — @melee points out in comments that the behavior of this particular setup is not always stable. If you carefully hold the mouse over towards the right edge of the "Home" <li> (near the ">" character), then sometimes the animation sort-of freaks out. It's not clear why, but the browser just gets very confused about where the elements should be rendered.

There are parameters to the STOP(), function, (true,true), (false,false) have you tried altering these to change the desired effect?

The definition of the stop function is

.stop( [ clearQueue ], [ jumpToEnd ] )

The oficial site goes...

clearQueue: A Boolean indicating whether to remove queued animation as well. Defaults to false.

jumpToEnd: A Boolean indicating whether to complete the current animation immediately. Defaults to false.

This is from http://api.jquery.com/stop/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!