当鼠标滚轮在HTML中的元素上滚动时执行脚本?
在元素上滚动鼠标滚轮时,将触发onwheel属性。
示例
当鼠标滚轮在HTML中的元素上滚动时,您可以尝试运行以下代码来执行脚本-
<!DOCTYPE html><html>
<head>
</head>
<body>
<div id = "myDIV" onwheel = "display()">This is demo text. Roll the mouse wheel here.</div>
<script>
function display() {
alert("使用鼠标滚轮!");
}
</script>
</body>
</html>
以上是 当鼠标滚轮在HTML中的元素上滚动时执行脚本? 的全部内容, 来源链接: utcz.com/z/322319.html