HTML onwheel Event Attribute

Description

The event attribute onwheel allows you to set the script to fire when using the mouse wheel on an element. The script also fires when the user scrolls or uses zoom on an element using the touch panel.

Syntax

<element onwheel="script">

Values

  • scriptThe name of the script to use when the event has been triggered.

Example

<!DOCTYPE html> 
  <html> 
    <head>
     <title>onwheel event</title> 
     <style> 
     div {
       border: 1px solid;
     }
     </style> 
    </head> 
    <body>
     <p>To demonstrate the onwheel event attribute, use the mouse wheel on the element:</p>
     <div id="wheeee" onwheel="wheeee()">The quick brown fox jumps over the lazy dog</div> 
<script> 
function wheeee () {
  document.getElementById("wheeee").style.fontSize="35px";
  document.getElementById("wheeee").style.color="blue";
} 
</script> 
  </body> 
</html>

Supported Tags

All HTML tags.

Browser Support

Desktop
Explorer Edge Chrome Firefox Opera Safari
YesYes61Yes48Yes
Tablets / Mobile
Android Chrome Firefox Opera Safari Samsung
6161Yes45YesX