ExampleChange background color of an element when the mouse pointer leaves it:
Try it yourself » |
The mouseleave event occurs when the mouse pointer leaves an element.
This event is mostly used together with the mouseenter event.
The mouseleave() method triggers the mouseleave event, or if the function parameter is set, it specifies what happens when a mouseleave event occurs.
Trigger the mouseleave event for the selected element.
|
Try it yourself » |
Specifies a function to run when the mouseleave event is triggered for the selected element.
|
Try it yourself » |
Parameter | Description |
---|---|
function | Optional. Specifies the function to run when the mouseleave event is triggered. |
![]() |
Try it Yourself - Examples |
The difference between mouseleave and mouseover
Demonstrates the difference between mouseleave and mouseover.