Skip to content
Related Articles

Related Articles

Improve Article

HTML | DOM onmouseenter Event

  • Last Updated : 04 Aug, 2021

The DOM onmouseenter event in HTML occurs when the mouse pointer is moved onto an element. This event is the opposite of onmouseleave event. 
This event is similar to the onmouseover event.
Supported Tags: It supports All HTML elements, EXCEPT: 

  • <base>
  • <bdo>
  •  <br>
  • <head>
  • <html>
  • <iframe>
  • <meta>
  • <param>
  • <script>
  • <style>
  • <title>

Syntax: 
 

  • In HTML: 
     
<element onmouseenter="myScript">
  • In JavaScript: 
     
object.onmouseenter = function(){myScript};
  • In JavaScript, using the addEventListener() method: 
     
object.addEventListener("mouseenter", myScript);

Example: Using the addEventListener() method 
 

html




<!DOCTYPE html>
<html>
 
<head>
    <title>
        HTML DOM onmouseenter Event
    </title>
</head>
 
<body>
    <center>
        <h1 id="demo">GeeksforGeeks</h1>
    </center>
    <script>
        document.getElementById(
          "demo").addEventListener(
          "mouseenter", enter);
 
        function enter() {
            document.getElementById(
              "demo").style.color = "green";
        }
    </script>
 
</body>
 
</html>

Output: 
 



Supported Browsers: The browsers supported by HTML DOM onmouseenter Event are listed below: 
 

  • Google Chrome 30.0
  • Internet Explorer 5.5
  • Firefox
  • Apple Safari 6.1
  • Opera 11.5

 

Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.

My Personal Notes arrow_drop_up
Recommended Articles
Page :