alex
alex

Reputation: 490547

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.

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 ... i.e. when the last content has appeared inside the div.

Is there a property or method to get the scrolled position within that div? Thanks

Upvotes: 2

Views: 244

Answers (2)

alex
alex

Reputation: 490547

I feel stupid... this returns a number I can use:

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

Upvotes: 0

Related Questions