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