HTML事件属性Onmousemove

HTML事件属性Onmousemove


触发 onmousemove 属性事件当鼠标指针在一个元素上移动时。

HTML5中的新功能

没有。

句法

<element onmousemove="script or Javascript function name">

支持的标签

所有HTML元素,EXCEPT:

<base>, 
<bdo>, 
<br>, 
<head>, 
<html>, 
<iframe>, 
<meta>, 
<param>, 
<script>, 
<style>, 
<title>


浏览器兼容性

Yes Yes Yes Yes Yes

例子

<!DOCTYPE html>
<html>
<body>

<p id="p1" onmousemove="onmouseMove()" onmouseup="mouseUp()">
Click the text! 
</p>

<script>
function onmouseMove() {
    console.log("move");
}

function mouseUp() {
    console.log("up");
}
</script>

</body>
</html>

Click to view the demo