CKTIS / HTML
onwheel — the wheel event handler
The global HTML attribute onwheel specifies code handling the wheel event. It is not a boolean attribute: its value contains JavaScript statements.
Version: WHATWG HTML Living Standard; index snapshot date recorded separately
Syntax
onwheel="JavaScript statements"
element.onwheel = function (event) { /* ... */ };
element.onwheel = null;onwheel is a global event-handler attribute available on all HTML elements. It corresponds to wheel, not scroll.
The attribute value is a JavaScript function body with an available event parameter. In contrast, assign a function to the element.onwheel property; another assignment replaces it, and null removes that handler. Content Security Policy can block attribute code.
The example dispatches a synthetic wheel event and sets the element's text to wheel. It does not simulate physical wheel movement or scrolling.
Examples
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>onwheel example</title>
<div id="area" onwheel="this.textContent = event.type">Ready</div>
<script>
const area = document.getElementById('area');
area.dispatchEvent(new Event('wheel'));
</script>
</html>Result
wheel
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.