HTML onmousewheel Event Attribute

Description

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

This is a deprecated attribute, please use onwheel attribute instead.

Syntax

<element onmousewheel="script">

Values

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

Example

<!DOCTYPE html> 
  <html> 
    <head>
     <title>onmousewheel event</title> 
     <style> 
     div {
       border: 1px solid;
     }
     </style> 
    </head> 
    <body>
     <p>To demonstrate the onmousewheel event attribute, use the mouse wheel on the element:</p>
     <div id="wheeee" onmousewheel="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
XXYesXXX
Tablets / Mobile
Android Chrome Firefox Opera Safari Samsung
YesYesXXXX