在元素上滚动鼠标滚轮时,将触发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>