简体   繁体   English

你能得到(如果可能的话,使用 jQuery)一个元素的当前滚动位置吗?

[英]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谢谢

我觉得很愚蠢……这会返回一个我可以使用的数字:

    console.log($('#text').attr('scrollTop'));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM