Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

HTML | DOM onmouseenter Event

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

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

 

My Personal Notes arrow_drop_up
Last Updated : 04 Aug, 2021
Like Article
Save Article
Similar Reads
Related Tutorials