The mouseleave() method triggers the mouseleave event when the mouse pointer leaves a selected element. It is a short-hand of the on('mouseleave', eventHandler) event.
$(selector).mouseleave(function());
This method accepts only one parameter, a function that gets invoked when the mouseleave() method triggers.
Let’s look at the code below:
In the HTML tab:
div content.jQuery script.In the JavaScript tab:
mouseleave() method on the div content.css() method to change the background color of the div content when mouseleave() is invoked.mouseleave() method is invoked when the mouse pointer leaves the square. As a result, the background color of the square changes.