jQuery unbind('hover') does not work

Aximili picture Aximili · Apr 28, 2010 · Viewed 8.7k times · Source

My unbind does not work.

$("img.hoverable").hover(ChangeImage, ChangeBack);
$("a img.hoverable").unbind('hover');

The HTML could be like this

<img class="hoverable" src="something.jpg"/>
<a href="#"><img class="hoverable" src="something.jpg"/></a>

When I hover over the second HTML, ChangeImage is still fired.

I am not sure if I am using it correctly, can anyone please advise?

Answer

rahul picture rahul · Apr 28, 2010

Try

$("img.hoverable").unbind('mouseenter mouseleave');

The .hover() method binds handlers for both mouseenter and mouseleave events. So inorder to unbind you will have to unbind mouseenter and mouseleave.