标题几乎不言而喻。那么我该如何使用jQuery或javascript来做这件事呢?我知道要判断滚动条是否到达了窗口的末端,应该是这样的。
$(window).scroll(function(){
if ($(window).scrollTop() == $(document).height() - $(window).height()){
alert('you have reached the bottom');
}
});那么,我如何判断它是否已到达特定部分,然后发出警报?谢谢。
发布于 2012-06-15 20:07:55
假设这不是一个难以解决的问题,但请查看jQuery Waypoints...一个非常好的插件来满足你的需求。
他们的网站上有一个简单的例子:
$('.entry').waypoint(function() {
alert('You have scrolled to an entry.');
});优雅,易于阅读,插件非常小,< 4kb。
发布于 2012-06-15 20:14:30
在没有插件的情况下实现这个的方法是这样的。
示例
// calculate where the bottom of the post is positioned
var postBottom = $(".post").offset().top + $(".post").height();
$(window).scroll(function(){
// check if the bottom of the post is smaller than the window height
if (postBottom < $(window).height()){
alert('you have reached the bottom of the post');
}
});https://stackoverflow.com/questions/11050309
复制相似问题