当鼠标滚动在 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("Mouse Wheel used!");
}
</script>
</body>
</html>
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP