I have a ul element with many li items:
<ul>
<li></li>
...
</ul>
when the user hovers their mouse over an li element, I'd like show some hidden buttons on the li, when they stop hovering, hide the buttons again. Trying to use delegate:
$("#myList").delegate("li", "hover", function () {
if (iAmHovered()) {
showButtons();
} else {
hideButtons();
}
});
the above gets called for both hover and 'un-hover'. How can I distinguish if it's a leave or enter though?
Also, I got this sample from this question: .delegate equivalent of an existing .hover method in jQuery 1.4.2
in which Nick says:
This depends on [#myList] not getting replaced via AJAX or otherwise though, since that's where the event handler lives.
I do replace the contents of #myList though, using:
$("#myList").empty();
will that cause a problem?
Thanks