HTML | DOM onmousemove Event
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 onreset Event
- HTML | DOM onscroll Event
- HTML | DOM oninvalid Event
- HTML | DOM ondrop Event
- HTML | DOM onfocus Event
- HTML | DOM touchmove Event
- HTML | DOM onseeked Event
- HTML | DOM onsearch Event
- HTML | DOM onresize Event
- HTML | DOM touchcancel Event
- HTML | DOM onmouseenter Event
- HTML | DOM ondblclick Event
- HTML | DOM onmouseleave Event
- HTML | DOM oncut 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.



