Home >Web Front-end >CSS Tutorial >Determine when the scroll bar slides to the bottom and trigger an event instance sharing

Determine when the scroll bar slides to the bottom and trigger an event instance sharing

小云云
小云云Original
2018-01-19 10:32:582512browse

This article mainly brings you an example to explain the event triggered when the scroll bar slides to the bottom. Has very good reference value. Let’s follow the editor and take a look. I hope it will be helpful to everyone. I hope it can help everyone.

The example is as follows:

$(document).on("scroll", function () {
 //真实内容的高度
 var pageHeight = Math.max(document.body.scrollHeight, document.body.offsetHeight);
 //视窗的高度
 var viewportHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight || 0;
 //隐藏的高度
 var scrollHeight = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
 //判断加载视频,文章,回答,医生
 if(pageHeight - viewportHeight - scrollHeight <=0){
  //事件
 }
});

Related recommendations:

jquery Enter key trigger event implementation method

How does js trigger an event after the mouse hovers for a certain period of time

jquery: solution to the problem of delegate repeatedly triggering events

The above is the detailed content of Determine when the scroll bar slides to the bottom and trigger an event instance sharing. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn