Some time ago, when writing the front-end, you need to listen to the scroll event of the browser.
I checked online and found two ways to monitor scroll events:
1. Native js listen through window.onscroll
//window.onscroll = function() {//To ensure compatibility, take two values here, which one has the value var scrollTop = document.documentElement.scrollTop || document.body.scrollTop; //scrollTop is the height of the scroll wheel when the scroll event is triggered}2. Jquery listens through $(window).scroll()
$(window).scroll(function(){//To ensure compatibility, take two values here, which one has the value var scrollTop = document.documentElement.scrollTop || document.body.scrollTop; //scrollTop is the height of the scroll wheel when the scroll event is triggered});When monitoring the roller event, you can obtain the height of the roller in real time. Through some process controls such as judging the roller height, some special effects based on the roller can be realized, such as: data loading asynchronously when the roller reaches the end, when the roller height is 0, and when the head is fixed and the head is fixed to a certain height, etc.
The above two ways to implement the JS monitor scroll wheel event are all the content I share with you. I hope you can give you a reference and I hope you can support Wulin.com more.