Javatpoint Logo
Javatpoint Logo

JavaScript onmousewheel event

The javascript mouse wheel event is the mouse event to navigate the html web page. The mouseListner uses the mouse wheel (onmousewheel) function to get the functionality after rolling the mouse. The mouse rolls up or down the web page and starts to operate the mouse wheel function using 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 "onmousewheel" function to show the mouse wheel event.

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

Examples

The following examples show the mouse wheel event with the different methods and functions.

Example 1: the following example shows the basic mouse 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 onmousewheel event

Example 2: the following example uses the mouse wheel event. The javascript uses the "mousewheel" event with the addEventListner method.

Output:

The image shows the activated mouse wheel events output page.

JavaScript onmousewheel event

Example 3: the following example uses the mouse wheel event. The javascript uses the "onmousewheel" event with the javascript handler.

Output

The image shows the activated mouse wheel events output page.

JavaScript onmousewheel 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 onmousewheel event

Conclusion

The "onmousewheel" function uses to roll the mouse wheel event, but advanced browsers deprecated the event. We can use the old version of browsers for the mouse wheel event.







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