当前位置 : 首页 » 编程语言 » 正文

判断滚动条滑到底部触发事件(实例讲解)

分类 : 编程语言 | 发布时间 : 2018-04-21 09:06:21 | 浏览 : 1

实例如下所示:

$(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){
  //事件
 }
});

相关阅读:

How to move an element into another element?

Set HTTP header for one request

Remove duplicates from an array of objects in JavaScript

Can I call jquery click() to follow an <a> link if I haven't bound an event handler to it with bind or click already?

Check whether a string matches a regex in JS

jQuery event to trigger action when a div is made visible

Check if user is using IE with jQuery

Resize HTML5 canvas to fit window

How do I replace a character at a particular index in JavaScript?

JavaScript file upload size validation