HTML | DOM onmouseover event
The DOM onmouseover event in HTML occurs when the mouse pointer is moved onto an element or its children.
Syntax:
- In HTML:
<element onmouseover="myScript">
- In JavaScript:
object.onmouseover = function(){myScript}; - In JavaScript, using the addEventListener() method:
object.addEventListener("mouseover", myScript);
Example:
<!DOCTYPE html> <html> <head> <title> DOM onmouseover event </title> </head> <body> <center> <h1 id="hID"> GeeksforGeeks </h1> <h2> HTML DOM onmouseover event </h2> <script> document.getElementById( "hID").addEventListener( "mouseover", over); document.getElementById( "hID").addEventListener( "mouseout", out); function over() { document.getElementById( "hID").style.color = "green"; } function out() { document.getElementById( "hID").style.color = "black"; } </script> </center> </body> </html> |
chevron_right
filter_none
Output:

Supported Browsers: The browsers supported by HTML DOM onmouseover event are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Apple Safari
- Opera
Recommended Posts:
- HTML | onmouseover Event Attribute
- HTML | Change Background color using onmouseover property
- HTML | DOM ondragstart Event
- HTML | DOM onseeking Event
- HTML | DOM ondrop Event
- HTML | DOM ondragenter Event
- HTML | DOM onwaiting event
- HTML | DOM onscroll Event
- HTML | DOM ondurationchange Event
- HTML | DOM transitionend Event
- HTML | DOM onmessage Event
- HTML | DOM ontoggle Event
- HTML | DOM ondragend Event
- HTML | DOM animationstart Event
- HTML | DOM ononline 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.



