Set the background color to yellow, when the mouse pointer enters a <p> element:
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.
Trigger the mouseenter event for the selected elements:
Attach a function to the mouseenter event:
|function||Optional. Specifies the function to run when the mouseenter event is triggered|
The difference between mouseenter() and mouseover()
Demonstrates the difference between mouseenter() and mouseover().
Your message has been sent to W3Schools.