我已经尝试了以下两种方法来显示每个div具有类名称头像带有隐藏的内容。jQuery mouseenter mouseleave工具提示
<div class="avatar"><a><img src="avatar.png" width="36" height="36"><div class="profile">Users Profile with Link</div></a></div>
第一个使用悬停和完美的作品时,我有页面上的多个虚拟形象元素。
不幸的是,工具提示内置了可点击的链接,悬停不允许我点击链接。
$('.avatar a').hover(function() {
$(this).contents('div:last-child').css({
display : 'inline'
});
}, function() {
$(this).contents('div:last-child').css({
display : 'none'
});
});
不幸的是,工具提示内置了一个可点击的链接,悬停不允许我点击链接。
我拼凑在一起的编码,我发现这里使用mouseenter和mouseleave。这一个也适用,它允许我点击链接。
var hover = null;
$('.avatar a').bind('mouseleave', function() {
var $this = $(this).contents('div:last-child');
hover = setTimeout(function() {
$this.fadeOut(400);
}, 800);
});
$('.avatar a').bind('mouseenter', function() {
$(this).contents('div:last-child').css({display:'block'});
if (hover !== null) {
clearTimeout(hover);
}
});
不幸的是,如果您将鼠标放在这些头像中的多个头像上,只有最后一个头像被移除,而其他头像会一直保留。
我的问题是我如何使用第二个将fadeOut当我移动到另一个工具提示?
我错过了什么吗?还是完全做错了?
您可以创建一个jsfiddle的例子吗? – Dom 2013-02-11 17:06:16
是的,我可以,就在这里。 http://jsfiddle.net/24MYq/ – Tim 2013-02-11 17:18:23