Questions tagged [scrolltop]

The scrollTop method. An element's scrollTop is a measurement of the distance of an element's top to its topmost visible content.

An element's scrollTop is a measurement of the distance of an element's top to its topmost visible content.


When an element content does not generate a vertical scrollbar, then its scrollTop value defaults to 0.

scrollTop can be set to any integer value, however:

  • If the element can't be scrolled (e.g. it has no overflow or if the element is non-scrollable), scrollTop is set to 0.
  • If set to a value less than 0, scrollTop is set to 0.
  • If set to a value greater than the maximum that the content can be scrolled, scrollTop is set to the maximum.

The .scrollTop() method, in jQuery is used to get or manipulate the current vertical position of the scroll bar for the first element in the set of matched elements or set the vertical position of the scroll bar for every matched element.

For more on this subject, please refere to the jQuery page, until further updates.

1197 questions
8
votes
2 answers

Getting the current scroll position in Chrome using scrollTop() on page load/refresh

Running the following in Chrome always returns 0: $(window).on('load', function(){ console.log($(window).scrollTop()); }); Running that same command via the console: $(window).scrollTop() Does return the correct number. (i.e.: 843) There are…
Chris
  • 3,680
  • 6
  • 26
  • 43
8
votes
3 answers

Can I disable / edit the automatic jump-to-top scroll when tapping status bar?

I'm using an app with a tableView that auto-scrolls downward, so tapping the status bar, which would normally jump to the top of the table, causes problems (it begins scrolling but if the auto-scroll ticks, it stops and leaves it somewhere in the…
Luke
  • 9,512
  • 15
  • 82
  • 146
8
votes
7 answers

How to get jQueryui dialog scrollTop to scroll dialog content to top

I have a jQueryui dialog which I'm loading in a lot of content (a terms of service agreement) which causes a scrollbar as the content overflows. This is as I would like it to be. However, I would like the scroll bar to be at the top (so users can…
Ross
  • 1,639
  • 1
  • 18
  • 22
7
votes
2 answers

Jquery: Scroll to last
  • I'm using the following to scroll to the last
  • in an unordered list: $("html,body").animate({scrollTop: $('ul#cart-items li').offset().top}); How can I change this to scroll to the last
  • in the unordered list, but also offset it about 30px…
  • floatleft
    • 6,243
    • 12
    • 43
    • 53
    7
    votes
    2 answers

    Vanilla JavaScript: Scroll to Top of Page

    I may have missed something, but I cannot get window.scrollTo(0,0) to move to the top of the page. I am implementing a sticky aside which works well enough. It uses .getBoundingClientRect() to get the initial position. However, if the page is partly…
    Manngo
    • 14,066
    • 10
    • 88
    • 110
    7
    votes
    2 answers

    jQuery scrollTop() position to percentage