菜单切换
FACESOHO知行者
心灵
记录
远方
赞赏工具
源代码:
点击运行
保存
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>小鸟启蒙(facesoho.com)</title> <style> #myDIV { border:1px solid black; } </style> </head> <body> <div id="myDIV">该实例演示了如何使用 HTML DOM 向 DIV 元素添加 "wheel" 事件。在这个区域上下滚动鼠标滚轮!</div> <p>当你在 div 元素中滚动鼠标滚轮时,脚本函数会设置 div 的字体大小为 35 像素。</p> <p><strong>注意:</strong> Internet Explorer 和 Safari 浏览器不支持 wheel 事件</p> <script> document.getElementById("myDIV").onwheel = function() {myFunction()}; function myFunction() { document.getElementById("myDIV").style.fontSize = "35px"; } </script> </body> </html>
运行结果