使用 jquery 使用户滚动后出现 div [英] Use jquery to make div appear after a user scrolls
本文介绍了使用 jquery 使用户滚动后出现 div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望在用户向下滚动页面后显示一个 div,如果他们滚动回顶部则消失.
I'd like to have a div appear after a user scrolls down on a page, and disappears if they scroll back to the top.
我认为在 jquery 中使用 .scroll() 函数会很有用,但无法弄清楚如何实现这一点.
I thought using the .scroll() function in jquery would be useful, but couldn't quite figure out how to make this happen.
任何帮助将不胜感激.谢谢!
Any help would be appreciated. Thanks!
推荐答案
这样的事情应该可以解决问题:
Something like this should do the trick:
$(window).scroll(function() {
if ($(this).scrollTop() == 0) {
$("#mydiv:visible").hide();
}
else {
$("#mydiv:hidden").show();
}
});
这篇关于使用 jquery 使用户滚动后出现 div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文