Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我希望在用户向下滚动页面后出现一个 div,如果他们滚动回顶部,它就会消失。
我认为在 jquery 中使用 .scroll() 函数会很有用,但不太清楚如何实现这一点。
任何帮助,将不胜感激。谢谢!
这样的事情应该可以解决问题:
$(window).scroll(function() { if ($(this).scrollTop() == 0) { $("#mydiv:visible").hide(); } else { $("#mydiv:hidden").show(); } });