onmousemove
定义和用法
onmousemove
属性在鼠标指针移动到元素时触发。
注意:onmousemove
属性不能使用于以下元素:<base>
、<bdo>
、<br>
、<head>
、<html>
、<iframe>
、<meta>
、<param>
、<script>
、<style>
、或<title>
。
语法
<element onmousemove="script">
浏览器支持
![]() | ![]() | ![]() | ![]() | ![]() |
所有主流浏览器都支持onmousemove 事件属性 |
示例
<html> <head> <script type="text/javascript"> function mouseOver() { document.getElementById('b1').src ="https://www.lanmper.cn" } function mouseOut() { document.getElementById('b1').src ="https://www.lanmper.cn" } </script> </head> <body> <a href="https://www.lanmper.cn" onmouseover="mouseOver()" onmouseout="mouseOut()"> <img alt="Visit W3School!" src="https://www.lanmper.cn" id="b1" /> </a> </body> </html>
HTML 4.01 与 HTML5之间的差异
无。
属性值
值 | 描述 |
---|---|
script | 规定该onmousemove 事件触发时执行的脚本。 |
实例
当鼠标指针移动到指定图片时运行脚本:<img onmousemove="bigimg(this)" src="smiley.gif" alt="smiley">