W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <body> <h1>WheelEvent deltaY 属性</h1> <p>通过在 DIV 元素内部滚动来调整其大小:</p> <div onwheel="myFunction(event)" style="width:100px;height:100px;background-color:Tomato"></div> <script> function myFunction(event) { var y = event.deltaY; var currentSize = event.target.style.width; if (y > 0) { newSize = parseInt(currentSize) + 10; } else { newSize = parseInt(currentSize) - 10; } event.target.style.width = newSize + "px"; event.target.style.height = newSize + "px"; } </script> </body> </html>