search

Home  >  Q&A  >  body text

javascript - How to solve the js mouse wheel event problem

When using jquery, the mouse wheelcan be triggered regardless of the height of the body(Please scroll the wheel under the result for the following address)
https://jsfiddle.net/shannon9/ 37fj5Lbs/embedded/

When using native js, when the height of the body is set (scroll bar appears), the mouse wheel event can be triggered:
https://jsfiddle.net/shannon9/05mfww8p/embedded/

Without setting a height for the body (that is, when no scroll bar appears), the mouse wheel event will not be triggered:
https://jsfiddle.net/shannon9/0ok2fd19/embedded /

How can I use native js to trigger the mouse wheel event like jquery when the height of the body is not set?

PHP中文网PHP中文网2795 days ago429

reply all(1)I'll reply

  • 伊谢尔伦

    伊谢尔伦2017-05-19 10:11:15

    //在控制台里输入
    document.body.onmousewheel = function(){console.log(1);}
    //然后滚动滚轮试试

    reply
    0
  • Cancelreply