代码示例:(标识:event_onwheel_dom)
<!DOCTYPE html>
<html>
<head>
<style>
#myDIV {
  border: 1px solid black;
}
</style>
</head>
<body>

<div id="myDIV">本例使用 HTML DOM 将 "onwheel" 事件分配给 DIV 元素。在我上面滚动鼠标滚轮 - 向上或向下!</div>

<p>当您在 div 上滚动鼠标滚轮时会触发一个函数。该函数将 div 的字体大小设置为 35 像素。</p>

<p><b>注释:</b>Internet Explorer 或 Safari 不支持 onwheel 事件。</p>

<script>
document.getElementById("myDIV").onwheel = function() {myFunction()};

function myFunction() {
  document.getElementById("myDIV").style.fontSize = "35px";
}
</script>

</body>
</html>
运行结果: