Javatpoint Logo
Javatpoint Logo

JavaScript onwheel mouse event

The mouse rolls up or down the web page and starts to operate the mouse wheel function using the "onwheel" javascript.

We can use the "onmousewheel" event, but it deprecates in the javascript. We can use the javascript for the "onwheel" attribute instead of the "onmousewheel" event.

Syntax

The following syntax uses the "onwheel" function to show the mouse wheel event.

The following syntax shows the mouse wheel event with the "wheel" function using the addEventListener event.

Examples

The examples describe the onwheel mouse event with different functions.

Example 1:

The following example shows the basic wheel event using javascript. We can use the event on the html tag with the function. Function changes font size and color when the mouse wheel event works.

Output

The image shows the activated mouse wheel events output page.

JavaScript onwheel mouse event

Example 2:

The following example uses the mouse "onwheel" event. The javascript uses the "wheel" event with the addEventListner Method.

Output

The image shows the activated mouse wheel events output page.

JavaScript onwheel mouse event

Example 3:

The following example uses the mouse wheel event. The javascript uses the "onwheel" event with the javascript handler.

Output

The image shows the activated mouse wheel events output page.

JavaScript onwheel mouse event

Example 4:

The following example uses the onwheel with the handler function on the body tag. When we scroll the wheel on the web page, the style tag changes and displays as per the handler.

Output

The image shows the activated mouse wheel events output page.

JavaScript onwheel mouse event

Conclusion

The onwheel event in javascript uses to scroll the wheel on the web page. We can scroll the page and tags with the advanced browser version.







Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA