Last Updated : 11 Jul, 2025
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.
<!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.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-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 OutputSupported Browsers:
The browser supported by onmousemove attribute 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