首页 > 【解决】[jQuery]mouseover,mouseenter,快速移动失效的问题。

【解决】[jQuery]mouseover,mouseenter,快速移动失效的问题。

在代码中使用mouserover,或是mouseenter,然后测试的时候,疯狂的在测试页面上移动mouseover的对象(复数), 一会就回出现mouseover失效的问题。然后慢慢的在放上去,就会恢复。请问有什么办法解决这个问题么?

代码如下

$('.s_c_pointer li').live("mouseover",function(){
                s_pointer = $(this).index();
                console.log(s_pointer);
                $('.s_c_pointer li').removeClass('active');
                $('.n_c_list li').removeClass('active').hide();
                $(this).addClass('active');
                $('.s_c_list:not(:animated)').stop(true).animate({'top': -(s_pointer * sl_height) + 'px'}, 'slow', function(){
                    console.log(s_pointer);
                    slider_ban = s_pointer;
                    $('.n_c_list li:eq(' + slider_ban + ')').show();
                    $('.news_coner').attr('id','bg' + slider_ban);  
                });

        });

问题解决了
将:not(:animated)删除即可。


貌似你的残余效果影响了下一个效果的触发,你在mouseover后,如果又触发了mouseenter,就在出发前及时清理上一个效果,避免影响当前的效果,mouseenter也一样。


不知道你说的失效是怎样,如果是动画延迟的话 你可以在他们每个动作触发之前加一个 stop()


没有动画效果的话,一般不太会失效吧,有动画效果的话,可以在处理函数里面检测一下动画状态

也可以加setTimeout阻止频繁调用处理函数

【热门文章】
【热门文章】