Open In App

HTML DOM onmousemove Event

Last Updated : 15 Jun, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

The DOM onmousemove event in HTML occurs when the pointer is moved 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>
    <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>
</body>
 
</html>


Output: 

 

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

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

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads