Home  >  Article  >  Web Front-end  >  html function onmousemove triggered when the mouse pointer moves over an element

html function onmousemove triggered when the mouse pointer moves over an element

黄舟
黄舟Original
2017-11-06 11:09:353798browse

Example

Execute a section of JavaScript when the mouse pointer moves over the image:

<img onmousemove="bigImg(this)" src="smiley.gif" alt="Smiley">

Browser support


IE

Firefox

Chrome

Safari

Opera


All major browsers All browsers support the onmousemove attribute.

Definition and Usage

The onmousemove attribute is triggered when the mouse pointer moves over an element.

Note: The onmousemove attribute does not apply to the following elements: dde6fb694e6711ae5e6f381704c04ae4, 71af07a0e88a1ac1ff73f855702ac153, 0c6dc11e160d3b678d68754cc175188a, 93f0f5c25f18dab9d176bd4f6de5d30e, 100db36a723c770d327fc0aef2ce13b1, d5ba1642137c3f32f4f4493ae923989c , e8e496c15ba93d81f6ea4fe5f55a2244, 0c68fef83818661b6da588c77ca3985e, 3f1c4e4b6b16bbbd69b2ee476dc4f83a, c9ccee2e6ea535a969eb3f532ad9fe89 or b2386ffb911b14667cb8f0f91ea547a7.

Differences between HTML 4.01 and HTML5

None.

Syntax

<element onmousemove="script">

Attribute value

Value Description
script Script to run when onmousemove occurs.

Example

Execute a piece of JavaScript when the mouse pointer moves over the image (to enlarge the image):

<!DOCTYPE html>  
<html>  
<head>  
<script>  
function bigImg(x)  
{  
x.style.height="180px";  
x.style.width="180px";  
}  
function normalImg(x)  
{  
x.style.height="128px";  
x.style.width="128px";  
}  
</script>  
</head>  
<body>  
<img onmousemove="bigImg(this)" onmouseout="normalImg(this)" border="0" src="/i/eg_smile.gif" alt="Smiley" >  
<p>函数 bigImg() 在鼠标指针移动到图像上时触发。此函数放大图像。</p>  
<p>函数 normalImg() 在鼠标指针移出图像时触发。此函数把图像的高度和宽度重置为正常尺寸。</p>  
  
</body>  
</html>


The above is the detailed content of html function onmousemove triggered when the mouse pointer moves over an element. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn