当鼠标滚轮滑过 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>
广告
数据结构
网络
关系数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
JavaScript
PHP