Skip to content
Related Articles

Related Articles

Improve Article

HTML | DOM onmousemove Event

  • Last Updated : 04 Aug, 2021

The DOM onmousemove event in HTML occurs when the pointer is move over an element.
Supported Tags: It supports All HTML elements, EXCEPT:

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

Syntax: 
 

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

Example: Using the addEventListener() method 
 

html




<!DOCTYPE html>
<html>
 
<head>
    <title>
        HTML DOM onmousemove Event
    </title>
</head>
 
<body>
    <center>
 
        <h1 id="eleID">GeeksforGeeks</h1>
 
        <p id="demo"></p>
 
 
        <script>
            document.getElementById(
              "eleID").addEventListener(
              "mousemove", function(event) {
                GFGfun(event);
            });
 
            function GFGfun(event) {
                alert("A computer science portal")
            }
        </script>
    </center>
</body>
 
</html>

Output: 
Before move: 
 



After move: 
 

Supported Browsers: The browsers supported by DOM onmousemove event are listed below: 
 

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Apple Safari
  • Opera

 

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 :