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