Siddharth Thevaril Siddharth Thevaril - 1 year ago 46
jQuery Question

jquery hover handlerOut to execute callback for specific cases

I have an HTML structure as this with a constraint that it cannot be modified


<div><a href="#"></a></div>
<div><a href="#"></a></div>
<div><a href="#"></a></div>

On hoverIn/ hoverOut on an
item, a corresponding
(with absolute positioning one behind another) will
which consists of some links.

Is it possible to modify the hoverOut handler in a way that it should execute a callback only if the hoverOut to hoverIn() is done from one
to another only?

In simple words the
shouldn't execute the callback if the mouse pointer goes from
to any other HTML entity except for another

Answer Source

Since you want to fadeIn and fadeOut on hovering on li only. I have created the hover function as follows :

$('ul li').hover(
    function() {
        var indexes = $( "li" ).index(this);

This will hide the div only on hovering li and will show when hovering on other elements.

Here is the jsFiddle

Hope it helps you :)