THE WORLD'S LARGEST WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

jQuery mouseenter() Method

jQuery Event Methods 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");
});
Try it Yourself »

Definition and Usage

The mouseenter event occurs when the mouse pointer is over (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 only triggers when the mouse pointer enters the selected element. The mouseover event is triggered if a mouse pointer enters any child elements as well. See the example at the end of the page for a demonstration.

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


Syntax

Trigger the mouseenter event for the selected elements:

$(selector).mouseenter() Try it

Attach a function to the mouseenter event:

$(selector).mouseenter(function) Try it

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

Examples

Try it Yourself - Examples

The difference between mouseenter(), mouseover() and mousemove()
Demonstrates the difference between mouseenter(), mouseover() and mousemove().


jQuery Event Methods jQuery Event Methods