![](/img/trans.png)
[英]How do I use JQuery to detect if a user scrolls to the bottom of the page?
[英]How to start a jQuery event when the user scrolls to the bottom of the page?
我正在尝试获取警报,以显示用户是否在页面底部100像素内滚动。 我正在让/ friends加载到div class = social,但是在滚动部分上遇到了麻烦。 关于我可以解决的任何建议吗?
<!--Load friends module -->
<script>
$(document).ready(function (){
$('.social').load("/friends");
});
</script>
<!--Load more videos if scroll within 100 pixels of bottom -->
<script type="text/javascript">
counter = 2;
$(document).ready(function (){
function loadMore() {
console.log("More loaded");
alert("test");
$('.more_videos').load("/more_videos/"+counter);
$(window).bind('scroll', bindScroll);
}
function bindScroll(){
if($(window).scrollTop() + $(window).height() > $(document).height() - 100) {
$(window).unbind('scroll');
loadMore();
}
}
$(window).scroll(bindScroll);
});
counter = counter+1;
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.