HTML onmousewheel Attribute

HTML onmousewheel Attribute: The HTML onmousewheel attribute is defined as it fires when the mouse wheel is rolled up or down over an element. The onmousewheel attribute is deprecated, you should use the onwheel attribute instead.



HTML onmousewheel Attribute

The HTML onmousewheel attribute can be applied to all the HTML elements.

Syntax: <element onmousewheel=”script”>

Browser Support:

The HTML onmousewheel attribute is supported by the following browsers:

  • Chrome
  • Safari
  • Firefox-does not support
  • Internet Explorer
  • Opera

Example: for <input> element

<!DOCTYPE html>
<html>
<head>
<style>
#myDIV {
  border: 1px solid black;
}
</style>
</head>
<body>

<div id="myDIV" onmousewheel="myFunction()">This example demonstrates how to assign an "onmousewheel" event to a DIV element. Roll the mouse wheel over me - either up or down!</div>

<script>
function myFunction() {
  document.getElementById("myDIV").style.fontSize = "35px";
}
</script>

</body>
</html>

Output:

HTML onmousewheel attribute