A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/html/html-dom-onmouseover-event/ below:

HTML DOM onmouseover event - GeeksforGeeks

HTML DOM onmouseover event

Last Updated : 15 Jun, 2023

The DOM onmouseover event in HTML occurs when the mouse pointer is moved onto an element or its children.

Supported Tags: It supports All HTML elements, EXCEPT: 

Syntax: 

<element onmouseover="myScript">
object.onmouseover = function(){myScript};
object.addEventListener("mouseover", myScript);

Example: In this example, we will see the use of DOM onmouseover event.

HTML
<!DOCTYPE html>
<html>
  
<head>
    <title>
        DOM onmouseover event
    </title>
</head>

<body>
    <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>
</body>

</html>

Output: 

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



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4