Code Editor
Web Browser
Learn
Mouse Events

On 'mouseleave'

One issue with the behavior we added to our Sole Shoes website in the last exercise is that the menu remains in the DOM after the mouse leaves the menu area.

The mouseleave event listener can detect when a user's mouse leaves the area that an element occupies. The syntax looks like:

$('.example-class').on('mouseleave', function() { // Execute code here when mouse leaves .example-class });

In the example code above, a user will trigger the callback function when their mouse leaves the .example-class area.

Report a Bug
If you see a bug or any other issue with this page, please report it here.