jQuery mouseout()
Method
Example
Set the background color to gray when the mouse pointer leaves the <p>
element:
$("p").mouseout(function(){
$("p").css("background-color","gray");
});
Definition and Usage
The mouseout event occurs when the mouse pointer leaves the selected element.
The mouseout() method triggers the mouseout event, or attaches a function to run when a mouseout event occurs.
Note: Unlike the mouseleave event, the mouseout event is triggered when the mouse pointer leaves the selected element or any of its child elements, while the mouseleave event is triggered only when the mouse pointer leaves the selected element. See the demo example at the bottom of the page.
Tip: This event is often used together with the mouseover event.
Syntax
Trigger the mouseout event for the selected elements:
Attach a function to the mouseout event:
Parameter | Description |
---|---|
function | Optional. Specifies the function to run when the mouseout event is triggered. |
More Examples
Difference between mouseout() and mouseleave()