當滑鼠滾動在 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