HTML onmousemove Event Attribute

The HTML onmousemove event attribute triggers JavaScript code when the mouse pointer moves over an element, allowing interaction based on mouse movement within the webpage.

Syntax: 

<element onmousemove = "script">

Attribute Value: This attribute contains single value script which works when onmousemove attribute called.

Supported Tags:

All HTML elements, EXCEPT

<base>Sets the base URL for all relative URLs.
<bdo>Overrides the text’s directionality.
<br>Inserts a single-line break.
<head>Contains metadata and links to stylesheets.
<html>Represents the root of an HTML document.
<iframe>Embeds another HTML page.
<meta>Provides metadata about the HTML document.
<param>Provides parameters for an object.
<script>Embeds client-side scripts.
<style>Defines style information for a document.
<title>Sets the title of the HTML document.

HTML onmousemove Event Attribute Example

Example: This example uses onmouseover event attribute to enlarge the image displayed when the cursor moves over the image.

html
<!DOCTYPE html>
<html>
    <head>
        <title>onmousemove event attribute</title>
    </head>
    <body>
        <center>
        <h2>onmousemove event attribute</h2>
        <img onmousemove="bigSize(this)" onmouseout="normalSize(this)"
        border="1px solod black" src=
"https://media.w3wiki.net/wp-content/uploads/w3wiki-9.png" 
        alt="gfg" width="300" height="100">
        <script>
            function bigSize(val) {
                val.style.height = "200px";
                val.style.width = "600px";
            }
            
            function normalSize(val) {
                val.style.height = "100px";
                val.style.width = "300px";
            }
        </script>
    </body>
</html>

Output: 

HTML onmousemove Event Attribute Example Output

Supported Browsers:

The browser supported by onmousemove attribute are listed below: