Jquery发现div是否在滚动时到达底部
我不能得到这个工作,有什么问题?
$("#scrollingbox").scroll(function() { //detect page scroll if($("#scrollingbox").scrollTop() + $("#scrollingbox").height() == $("#scrollingbox").height()) //user scrolled to bottom of the page? { //do something } }
发生的事情是我需要再次向上滚动才能检测到它到达底部。
http://jsfiddle.net/collabcoders/v2RbN/1/
$("span").hide(); $(".box").scroll(function() { if($(this).scrollTop() + $(this).innerHeight() >= $(this)[0].scrollHeight) { $("span").show(); } else { $("span").hide(); } })