[英]Can you get (using jQuery if possible) the current scrolled position of an element?
I am using this code on a 'down' button to scroll text in an overflowed div.我在“向下”按钮上使用此代码在溢出的 div 中滚动文本。
var textHeight = text.outerHeight();
var pageDown = $('#page-down');
var pageUp = $('#page-up');
pageDown.bind('click', function () {
pageUp.fadeIn(500);
text.animate({ scrollTop: '+=' + textHeight + 'px' }, 500);
});
This is working nicely, but I need a method to determine when the scroll down button should disappear ... ie when the last content has appeared inside the div.这工作得很好,但我需要一种方法来确定向下滚动按钮何时应该消失......即当最后一个内容出现在 div 中时。
Is there a property or method to get the scrolled position within that div?是否有属性或方法可以获取该 div 中的滚动位置? Thanks谢谢
Here's a couple links you may want to look at:以下是您可能想要查看的几个链接:
http://yelotofu.com/2008/10/jquery-how-to-tell-if-youre-scroll-to-bottom/ http://yelotofu.com/2008/10/jquery-how-to-tell-if-youre-scroll-to-bottom/
http://www.mail-archive.com/jquery-en@googlegroups.com/msg22400.html http://www.mail-archive.com/jquery-en@googlegroups.com/msg22400.html
我觉得很愚蠢……这会返回一个我可以使用的数字:
console.log($('#text').attr('scrollTop'));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.