Please note, this is a STATIC archive of website www.w3schools.com from 05 May 2020, cach3.com does not collect or store any user information, there is no "phishing" involved.
THE WORLD'S LARGEST WEB DEVELOPER SITE

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");
});
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

Try it Yourself - Examples

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


❮ jQuery Event Methods