jQuery mouseenter()Method
Example
When the mouse pointer enters the <p> element, set the background color to yellow:
Try it yourself »
Definition and Usage
When the mouse pointer passes through (enters) the selected element, the mouseenter event occurs.
The mouseenter() method triggers the mouseenter event, or adds a function to run when the mouseenter event occurs.
Note:andmouseoverThe events are different: the mouseenter event is only triggered when the mouse pointer enters the selected element, while the mouseover event is also triggered when the mouse pointer enters any child element. See the demonstration example at the bottom of the page.
Tip:This event is usually used withmouseleaveevent.
Syntax
Trigger the mouseenter event of the selected element:
Add a function to the mouseenter event:
| Parameters | Description |
|---|---|
| function | Optional. Specifies the function to run when the mouseenter event is triggered. |
More Examples
The difference between mouseenter() and mouseover()
Demonstrate the difference between mouseenter() and mouseover().
Other Extensions
jQuery Event Methods