$('.WallEntry').live('mouseover mouseout', function(event) {
if (event.type == 'mouseover') {
$(this).find('.delButton').css('visibility', 'visible');
}else{
$(this).find('.delButton').css('visibility', 'hidden');
}
});
CSS:
.WallEntry{
width: 300px;
}
HTML
<div class='WallEntry'>
Message: <br>
Hi, have you been there..?
<div style='visibility: hidden' class='delButton'></div>
</div>
What I would like to do:
When you hover the message(the element WallEntry), the delButton should appear. When you mouseaway away, it should hide.
I have tried:
$(".WallEntry").live("hover", function(){
$(this).find('.delButton').css('visibility', 'visible');
}, function() {
$(this).find('.delButton').css('visibility', 'hidden');
});
But then I got told that live() doesnt handle two functions.
My code at top´s issue is that it doesn’t show the delButton on the appended div elements with WallEntry.
How should this be done?
I suggest, if you don’t need to support IE6, removing all of your script for the hover, and just doing this in CSS:
If you have to support IE6, use this CSS:
And this script:
Or, to be completely safe:
And if the parent container has an ID, the
.delegate()version: