What is the difference between the event listener mouseleave and the method .mouseleave()?


#1

Question

What is the difference between the event listener mouseleave and the method .mouseleave()?

Answer

Some jQuery event listeners have shortcut notations, including the mouseleave event listener. To use the event listener mouseleave the syntax looks like this:

$('target-element').on('mouseleave', callback function);

While the shortcut method .mouseleave() is used like this:

$('target-element').mouseleave(callback function);

Note that other jQuery event listeners like mouseenter, mousemove, mouseover, and others have shortcut notations as well. Please check the jQuery documentation for Events to see more info!


FAQ: Mouse Events - On 'mouseleave'