onmousemove属性用来获取或设置当前元素的mousemove事件的事件处理函数
将鼠标指针移到图像上时执行JavaScript:
<!DOCTYPE html>
<html>
<head>
<title>HTML onmousemove 事件属性的使用(基础教程网 (niaoge.com))</title>
</head>
<body>
<img onmousemove="bigImg(this)" onmouseout="normalImg(this)" border="0" src="pig.gif" alt="pig" width="32" height="32">
<p>当用户鼠标指针移到图像上方时,将触发bigImg()函数。此功能放大图像。<br>
当鼠标指针移出图像时,将触发normalImg()函数。该功能将图像的高度和宽度设置为正常。</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>
测试看看 ‹/›IEFirefoxOperaChromeSafari
所有主流浏览器都支持 onmousemove 事件属性
当指针在元素上移动时,onmousemove属性将触发。
注意: onmousemove 属性不能使用于以下元素: <base>, <bdo>, <br>, <head>, <html>, <iframe>, <meta>, <param>, <script>, <style>, 或<title>。
没有。
<element onmousemove="script">
值 | 描述 |
---|---|
script | 规定该onmousemove事件触发时执行的脚本。 |