X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

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


Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates FREE Website Templates Free HTML Templates

SHARE THIS PAGE

facebook