JavaScript onwheel mouse eventThe 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. SyntaxThe 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. ExamplesThe 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. 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. 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. 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. ConclusionThe 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. Next TopicMouseout event in javascript |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India