English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Reference Manual

HTML Tag大全

HTML onmousemove event attribute

The onmousemove attribute is used to get or set the event handler function for the current element's mousemove event

HTML Event Attributes

Online Example

Execute JavaScript when the mouse pointer is moved over the image:

<!DOCTYPE html>
<html>
<head>
<title>Use of HTML onmousemove Event Attribute (Basic Tutorial Website oldtoolbag.com)</title>
</head>
<body>
<img onmousemove="bigImg(this)" onmouseout="normalImg(this)" border="0" src="pig.gif" alt="pig" width="32" height="32">
<p>When the user's mouse pointer moves over the image, the bigImg() function is triggered. This function enlarges the image.<br>
When the mouse pointer moves out of the image, the normalImg() function is triggered. This function sets the height and width of the image to normal.</p>
<script>
function bigImg(x) {
  x.style.height = "64px";
  x.style.width = "64px";
}
function normalImg(x) {
  x.style.height = "32px";
  x.style.width = "32px";
}
</script>
</body>
</html>
Test it out ‹/›

Browser Compatibility

IEFirefoxOperaChromeSafari

All major browsers support the onmousemove event attribute

Definition and Usage

The onmousemove attribute will be triggered when the pointer moves over the element.

Note: The onmousemove attribute cannot be used on the following elements: <base>, <bdo>, <br>, <head>, <html>, <iframe>, <meta>, <param>, <script>, <style>, or <title>.

HTML 4.01 With HTML5Differences

None.

Syntax

<element onmousemove="script">

Attribute Value

ValueDescription
scriptSpecifies the script to be executed when the onmousemove event is triggered.
HTML Event Attributes