jquery悬停最后一个元素失败

发布于 2024-12-15 21:13:51 字数 1296 浏览 4 评论 0原文

我有几个在传递鼠标时动画的div:

<div class="ivideo">
<a href="#">
<img src="default01.jpg" width="190" height="142" />                
</a>
</div>

<div class="ivideo">
<a href="#">
<img src="default02.jpg" width="190" height="142" />                
</a>
</div>

<div class="ivideo">
<a href="#">
<img src="default03.jpg" width="190" height="142" />                
</a>
</div>

我在这种情况下使用hoverIntent jquery插件:

var configVideo = {
                sensitivity: 3,
                interval: 100,
                over: videoOver,
                timeout: 200,
                out: videoOut
            };

    $(".ivideo").hoverIntent( configVideo );

    function videoOver(){
        $('img',this).animate({ 
                opacity: 0.3
            }, 100 );

            $('<span><\/span>').appendTo($('a',this));
            $('span',this).fadeIn(100);

    }

    function videoOut(){
            $('img',this).animate({ 
                opacity: 1
            }, 100 );

            $('span',this).fadeOut(100 ,function() {$(this).remove()});
    }

我的问题是所有元素反应良好(当我快速使用鼠标时),但最后一个div总是会失败(总是卡在mouseout中)事件)

我的错误是什么?我希望你的帮助。

I have several divs that animate when passing the mouse:

<div class="ivideo">
<a href="#">
<img src="default01.jpg" width="190" height="142" />                
</a>
</div>

<div class="ivideo">
<a href="#">
<img src="default02.jpg" width="190" height="142" />                
</a>
</div>

<div class="ivideo">
<a href="#">
<img src="default03.jpg" width="190" height="142" />                
</a>
</div>

I use hoverIntent jquery plugin for this case:

var configVideo = {
                sensitivity: 3,
                interval: 100,
                over: videoOver,
                timeout: 200,
                out: videoOut
            };

    $(".ivideo").hoverIntent( configVideo );

    function videoOver(){
        $('img',this).animate({ 
                opacity: 0.3
            }, 100 );

            $('<span><\/span>').appendTo($('a',this));
            $('span',this).fadeIn(100);

    }

    function videoOut(){
            $('img',this).animate({ 
                opacity: 1
            }, 100 );

            $('span',this).fadeOut(100 ,function() {$(this).remove()});
    }

My problem is that all elements react well (when I use the mouse quickly) but the last div will always fail (always get stuck in the mouseout event)

What would be my mistake? I hope your help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

獨角戲 2024-12-22 21:13:51

看这里

实际上,所有元素都会失败,但你一个接一个地快速测试它们,并在出现时用鼠标停止你哪里完成了,对吧?
问题是 div 将自动具有 100% 的宽度,因此如果您不使用鼠标向下或离开文档,则无法离开它。
这就是为什么您需要设置固定宽度或使用其他元素。

Look here

Actually all elements will fail but you tested them fast one after the other and stopped with the mouse when you where finished, right?
The problem is that a div will automatically have a width of 100% so there is no way to go out of it of you don't go down or out of the document with your mouse.
Thats why you need to set a fixed width or use another element.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文