Jquery 聚焦时工具提示淡出
我有一个简单的代码,当您将鼠标悬停在某个元素上时,我会在其中显示工具提示(通过更改display属性)。当我将鼠标悬停在工具提示上时,有没有一种方法使工具提示不会消失Jquery 聚焦时工具提示淡出,jquery,Jquery,我有一个简单的代码,当您将鼠标悬停在某个元素上时,我会在其中显示工具提示(通过更改display属性)。当我将鼠标悬停在工具提示上时,有没有一种方法使工具提示不会消失 $('.element').mouseenter(function(){ $(this).find('.tooltip').fadeIn(); }).mouseleave(function(){ $(this).find('.tooltip').fadeOut(); // I want the
$('.element').mouseenter(function(){
$(this).find('.tooltip').fadeIn();
}).mouseleave(function(){
$(this).find('.tooltip').fadeOut(); // I want the tooltip to not fadeout if move is over tooltip element
});
我会说
$('.tooltip,.element').mouseenter(function() {
$(this).find('.tooltip').fadeIn();
}).mouseleave(function() {
$(this).find('.tooltip').fadeOut();
});
如果在工具提示和元素之间有一个空格,那么在隐藏之前需要一个延迟,在这种情况下,我建议您使用一个插件,比如优秀插件。Description
如果工具提示是.element
的子元素,则它不会被禁用
另一件事,我建议您使用jQuery的.hover()
方法
看看我的样品和这个
样品
盘旋我
我是你的工具提示
$('.element').hover(函数(){
$(this.find('.tooltip').fadeIn();
},函数(){
$(this.find('.tooltip').fadeOut();
});
更多信息
,它不会触发悬停事件2次吗?如果它属于元素,则工具提示
悬停?@Glide我也这么认为;)非常感谢。
<div class="element">
hover me
<div style="display:none" class="tooltip">Iam your tooltip</div>
</div>
$('.element').hover(function(){
$(this).find('.tooltip').fadeIn();
}, function(){
$(this).find('.tooltip').fadeOut();
});
$(this).find('.tooltip').mouseover(function(){
$(this).find('.tooltip').stop().fadeTo('fast', 1);
});
$(this).find('.tooltip').mouseout(function() {
$(this).find('.tooltip').stop().fadeTo('fast', 0);
});