The DOM onmousemove event in HTML occurs when the pointer is move over an element.
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
<!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> |
chevron_right
filter_none
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
Recommended Posts:
- HTML | onmousemove Event Attribute
- HTML | DOM fullscreenerror Event
- HTML | DOM onvolumechange Event
- HTML | DOM onopen Event
- HTML | DOM ondragleave Event
- HTML | DOM onpaste Event
- HTML | DOM touchcancel Event
- HTML | DOM touchmove Event
- HTML | DOM Storage Event
- HTML | DOM createEvent() Event Method
- HTML | DOM touchend Event
- HTML | DOM timeStamp Event Property
- HTML | DOM stopPropagation() Event Method
- HTML | DOM cancelable Event Property
- HTML | DOM type Event Property
- HTML | DOM touchstart Event
- HTML | DOM onpause Event
- HTML | DOM onabort Event
- HTML | DOM onsuspend Event
- HTML | DOM oninvalid Event
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


