Easy Tutorial
❮ Html Prepend Jquery Ref Misc ❯

jQuery mouseenter() Method

jQuery Event Methods

Example

Set the background color to yellow when the mouse pointer enters a <p> element:

$("p").mouseenter(function(){
    $("p").css("background-color","yellow");
});

Definition and Usage

The mouseenter event occurs when the mouse pointer enters the selected element.

The mouseenter() method triggers the mouseenter event, or attaches a function to run when a mouseenter event occurs.

Note: Unlike the mouseover event, the mouseenter event is only triggered when the mouse pointer enters the selected element. The mouseover event is also triggered when the mouse pointer enters any child element. See the demo example at the bottom of the page.

Tip: This event is often used together with the mouseleave event.


Syntax

Trigger the mouseenter event for the selected elements:

Attach a function to the mouseenter event:

Parameter Description
function Optional. Specifies the function to run when the mouseenter event is triggered.

More Examples

Difference between mouseenter() and mouseover()


jQuery Event Methods

❮ Html Prepend Jquery Ref Misc ❯