HTML event attribute onwheel








The onwheel attribute event is triggered when the mouse wheel is rolled up or down.

What's new in HTML5

The onwheel attribute is new in HTML5.

Syntax

<element onwheel="script or Javascript function name">

Supported Tags

All HTML elements

Browser compatibility

onwheel Yes Yes Yes Yes Yes




Example

<!DOCTYPE html>
<html>
<head>
<style>
#myDIV {<!--from  ww w  .  j ava2  s  .  co  m-->
    border: 1px solid black;
}
</style>
</head>
<body>

<div id="myDIV" onwheel="myFunction()">
This is a test. This is a test. This is a test. This is a test. This is a test. 
This is a test. This is a test. This is a test. This is a test. This is a test. 
This is a test. This is a test. This is a test. This is a test. This is a test. 
This is a test. This is a test. This is a test. This is a test. This is a test. 
This is a test. This is a test. This is a test. This is a test. This is a test. 
This is a test. This is a test. This is a test. This is a test. This is a test. 
</div>

<script>
function myFunction() {
    console.log("wheel");
}
</script>

</body>
</html>

Click to view the demo