本文介绍了jquery:检测滚动位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在滚动时看到我的页脚来查看。
I want to get an alert when, while scrolling, my footer comes to view.
$(window).on("mousewheel", function(){
if ($(window).scrollTop() + $(window).height() > $('#footer').position().top){
alert("footer visible");
}
else{
alert("footer invisible");
}
});
所有带高度的条件似乎都是正确的,但在滚动期间不会。
All conditions with height seem right, but not during scrolling.
推荐答案
工作
试试这个
Working DEMO
Try this
$(window).scroll(function () {
if ($(window).scrollTop() + $(window).height() > $('.footer').offset().top) {
alert("footer visible");
} else {
alert("footer invisible");
}
});
希望这会有所帮助,谢谢
Hope this helps,Thank you
这篇关于jquery:检测滚动位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!