I have tried the following two methods to display hidden contents that comes with each div that has the class name avatar.
<div class="avatar"><a><img src="avatar.png" width="36" height="36"><div class="profile">Users Profile with Link</div></a></div>
The first one uses hover and works perfectly when I have multiple avatar elements on the page.
Unfortunately the tool tip has a clickable link built in and hover does not allow me to click on the link.
$('.avatar a').hover(function () {
$(this).contents('div:last-child').css({
display : 'inline'
});
}, function () {
$(this).contents('div:last-child').css({
display : 'none'
});
});
Unfortunately the tool tip has a clickable link built in and hover does not allow me to click the link.
I than pieced together coding that I found here that uses mouseenter and mouseleave. This one also works and it allows me to click the link.
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);
}
});
Unfortunately if you mouse over more than one of these avatars only the last one gets removed while others always remain.
My question is how do I use the second one which will fadeOut any active tool tips when I move on to another?
Am I missing something? Or doing this wrong altogether?