Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

jQuery mouseover() method

jQuery mouseover() method

jQuery event methods jQuery event methods

Example

When the mouse pointer is over the

element, set the background color to yellow:

$("p").mouseover(function(){

$("p").css("background-color","yellow");

});

Try it »


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:** Unlike the mouseenter event, 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 demo at the bottom of the page.

**Tip:** This event is usually used together with the mouseout event.


Syntax

Trigger the mouseover event of the selected element:

$(

selector

).mouseover()

Try it

Add a function to the mouseover event:

$(

selector

).mouseover(

function

)

Try it

Parameters Description
function Optional. Specifies the function to run when the mouseover event is triggered.

More examples

The difference between mouseover() and mouseenter()
Demonstrate the difference between mouseover() and mouseenter().


jQuery event methods jQuery event methods