jQuery mouseout()Method
Example
When the mouse pointer leaves the <p> element, set the background color to gray:
Try it yourself »
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:and mouseleaveDifference between events: the mouseout event is triggered when the mouse pointer leaves the selected element or any child element, while the mouseleave event is only triggered when the mouse pointer leaves the selected element. See the demonstration example at the bottom of the page.
Tip:This event is usually used together with the mouseoverevent.
Syntax
Trigger the mouseout event on the selected element:
Attach a function to the mouseout event:
| Parameters | Description |
|---|---|
| function | Optional. Specifies the function to run when the mouseout event is triggered. |
More Examples
The difference between mouseout() and mouseleave()
Demonstrate the difference between mouseout() and mouseleave().
Other Extensions
jQuery Event Methods