JavaScript onmouseenter Event

You are Here:

JavaScript onmouseenter Event

The onmouseenter event occurs when the mouse pointer is entered onto an element.

Note: Unlike onmouseover event, the onmouseenter event will NOT bubble, i.e., The element with onmouseenter event will NOT be affected when the mouse pointer is entered onto its child element.

onmouseenter Event as Attribute


HTML Online Editor
<!DOCTYPE html> <html> <body> <p onmouseenter="myFunction()">Touch me</p> <script> function myFunction(){ document.write("You touched"); } </script> </body> </html>


As Attribute

<element onmouseenter = "JavaScript">

As Property

object.onmouseenter = function(){ // code };

Using Event Listener

object.addEventListener("mouseenter" , myScript);

onmouseenter Event as Property


HTML Online Editor
<!DOCTYPE html> <html> <body> <p>Touch anywhere</p> <script> function myFunction(){ document.write("You touched"); } document.onmouseenter = myFunction; </script> </body> </html>

Using addEventListener() Method

Note: The addEventListener() method is not supported in Internet Explorer 8 and below.


HTML Online Editor
<!DOCTYPE html> <html> <body> <p>Touch me</p> <script> var x = document.getElementsByTagName("p")[0]; function myFunction(){ document.write("You touched"); } x.addEventListener("mouseenter", myFunction); </script> </body> </html>

onmouseover vs onmouseenter

Check out the difference between onmouseover vs onmouseenter in javascript.


Hi Developers, we almost covered 97% of JavaScript Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in JavaScript.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author