Possible Duplicate:
Using delegate() with hover()?
I am trying this code, but apparently I am doing something wrong. With this code the hover effect doesn’t work.
However something like : $('.group>span').hover (function() { works well but I need to delegate the html() content.
<div class="group">
<span></span>
</div>
$('.group>span').delegate("hover", "a", function() {
$(this).html('<a href="#new_list">Some button</a>');
}, function() {
$(this).empty();
});
Any idea? thanks
The number of arguments you pass to the
delegateis invalid. You pass 4 while it should take only 3..delegate( selector, eventType, handler(eventObject) )is the function signature.And the order of the parameters in your code is wrong! you swapped the selector and the event type
You wrote this:
While it should be in this order:
Anyway you can use
delegateforhoverthis way :LIVE DEMO
You can see another way to go in this question:
Using delegate() with hover()?