Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to correctly make a onmouseout event for a UL?

Check this simple code:

<ul onmouseout='alert(1)'>
    <li>aaaaaaaaaaaaaaaaaaaaaaaa</li>
    <li>bbbbbbbbbbbbbbbbbbbbbbbbb</li>
    <li>ccccccccccccccccccccccccc</li>
</ul>

The onmouseout event is fired even when I am inside the UL traversing the LI with the mouse.

This is with FireFox, how can I make it right, so the event is fired when I really leave the UL?

like image 716
Itay Moav -Malimovka Avatar asked Feb 23 '23 20:02

Itay Moav -Malimovka


1 Answers

You can use the jQUery mouseout, or the jQuery mouseleave functions for this, The same exists for Mootools.

EDIT

The mouse out event will be triggered whenever you leave one li and go to the next, but mouseleave is triggered only on leaving the whole of the div

$('#id').mouseleave(function(){
alert("left the div");  
});
like image 142
Balanivash Avatar answered Feb 26 '23 22:02

Balanivash