English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The onmousemove attribute is used to get or set the event handler function for the current element's mousemove event
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 ‹/›
IEFirefoxOperaChromeSafari
All major browsers support the onmousemove event attribute
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>.
None.
<element onmousemove="script">
Value | Description |
---|---|
script | Specifies the script to be executed when the onmousemove event is triggered. |