This example demonstrates how to assign an "onwheel" event event to a DIV element.
A function is triggered when you roll the mouse wheel over div.
The function sets the font-size of div to 35 pixels.
<!DOCTYPE html> <html> <head> <style> #myDIV {/*from w w w . j a va 2 s . c o m*/ border: 1px solid black; } </style> </head> <body> <div id="myDIV" onwheel="myFunction()"> Roll the mouse wheel over me - either up or down!</div> <script> function myFunction() { document.getElementById("myDIV").style.fontSize = "35px"; } </script> </body> </html>
Bubbles: | Yes |
---|---|
Cancelable: | Yes |
Event type: | WheelEvent |
Supported HTML tags: | All HTML elements |