Latest web development tutorials

onwheel event

Event Object Reference Event objects

Examples

Executed when the user rolls the mouse wheel on the <div> element in JavaScript:

. Document.getElementById ( "myDIV") addEventListener ( "wheel", myFunction);

function myFunction () {
. Document.getElementById ( "myDIV") style.color = "red";
}

try it"


Definition and Usage

onwheel event fires when the mouse wheel to scroll up and down the element.

onwheel event can also scroll or zoom in on the touch pad triggers (such as the touchpad on the notebook) while the area reduced.


Browser Support

event
onwheel 31.0 9.0 17.0 not support 18.0

Note: The methods support wheel event in IE browser, only through addEventListener (). No onwheel property DOM object.


grammar

In HTML:

<Elementonwheel = "myScript"> try

In JavaScript:

object .onwheel = function () {myScript }; try

JavaScript, use the addEventListener () method:

object .addEventListener ( "wheel", myScript ); try

Note: Internet Explorer 8 and earlier versions of IE do not support addEventListener () method.


technical details
Whether to support the bubble: Yes
It can be canceled: Yes
Event Type: WheelEvent
Supported HTML tags: All HTML elements


Event Object Reference Event objects