Mouseout和Mouseenter jQuery函数 [英] Mouseout and Mouseenter jquery function

查看:122
本文介绍了Mouseout和Mouseenter jQuery函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用了jQuery mouseout和mouseenter函数.但是效果不好.因为当您快速浏览项目时.我得到了非常疯狂的效果.我使用了以下代码:

I used the jQuery mouseout and mouseenter function. But is not working good. Because when you go fast over the items. I get verry crazy effects. I used this code:

$('.hover').css('opacity', 1);
    $('.controlNav li').mouseover(function() {
        $('.hover', this).css({ display: 'block' }).animate({ top: -73, opacity: 1 }, 450, 'swing' );
    }).mouseout(function(){
        $('.hover', this).css({ display: 'none' }).animate({ top: -60, opacity: 0 });
    });

我该如何解决我的问题?

How can i fix my problem?

推荐答案

我在.stop()之前添加了动画,它将停止动画并停止跳跃.

I added in .stop() just before the animation which will stop the animation in place and should stop the jumping.

$('.controlNav li').mouseover(function() {
    $('.hover', this).css({ display: 'block' }).stop().animate({ top: -73, opacity: 1 }, 450, 'swing' );
}).mouseout(function(){
    $('.hover', this).css({ display: 'none' }).stop().animate({ top: -60, opacity: 0 });
});

这篇关于Mouseout和Mouseenter jQuery函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆