jQuery显示悬停时的元素 [英] jquery showing elements on hover

查看:99
本文介绍了jQuery显示悬停时的元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的页面上有多个divs(myDiv).当用户将鼠标悬停在一个div上时,我希望:经过一段时间的延迟后,在顶部显示另一个div(myPop).几乎像一个工具提示.下面的代码只是没有完全做到这一点.如果用户在多个myDiv上移动鼠标,则可以等待并查看所有myPops淡入.我真的只想完全隐藏用户先前导致被淡入的所有myPops.因为您最终会显示所有这些myPops的尾随效果.

I have a number of divs(myDiv) on a page. When the user hovers over one of the divs I would like to: after a little delay, display another div(myPop) on top. Almost like a tooltip. The code below is just not quite doing it. If the user moves the mouse across a number of myDivs then you can wait and see all the myPops fadein. I really want to just completely hide all the myPops that the user previously caused to be fadeIn. Because you end up with sort of trailing effect of all these myPops being displayed.

   $(".myDiv").hover(function () {
    $(this).find(".myPop").fadeIn('slow');
}, function () {
    $(this).find(".myPop").fadeOut('fast');
}
});

推荐答案

尝试:

$(".myDiv").hover(function () {
    $(".myPop").stop();
    $(this).find(".myPop").fadeIn('slow');
}, function () {
    $(this).find(".myPop").fadeOut('fast');
});

这篇关于jQuery显示悬停时的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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