當滑鼠滾輪滑過 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