如何查看用户是否使用jQuery滚动到表格末尾?我可以找到何时用户滚动到页面的末尾使用此:当用户滚动到指定表格末尾时查找
if(document.body.scrollHeight - $(window).scrollTop() <= $(window).height()) {
// do something
}
但我该如何做一个表,例如, $(#table-name)
?
非常感谢:)。
如何查看用户是否使用jQuery滚动到表格末尾?我可以找到何时用户滚动到页面的末尾使用此:当用户滚动到指定表格末尾时查找
if(document.body.scrollHeight - $(window).scrollTop() <= $(window).height()) {
// do something
}
但我该如何做一个表,例如, $(#table-name)
?
非常感谢:)。
试试这个。
$(document).scroll(function() {
var $table = $("#table-name");
if ($table.position().top + $table.height() - $(window).height() <= $(window).scrollTop()) {
console.log('Reached end of table');
}
});
$(document).scroll(function() {
if ($("table")[0].scrollHeight - $(window).scrollTop() <= $(window).height()) {
alert("hello");
}
});
还有一个jQuery插件这一点,这包括了很多其他功能: