Scrollbar
And the last pair of methods I'd like to tell you about:
returns the horizontal scroll position for the first element in the selection
sets the horizontal scroll value for each element in the selection
returns the vertical scroll position for the first element in the selection
sets the vertical scroll value for each element in the selection
Here's how we can find out the "distance" traveled from the top of the page:
$('html').scrollTop();Or we can "jump" to the very top of the page:
$('html').scrollTop(0);The scrollTop and scrollLeft values can be animated and don't work for hidden DOM elements:
$('html').animate({ scrollTop: '+=200px' });There are really a lot of methods, and I don't always remember what each one does either (especially when it comes to the wrap family), so don't bother memorizing everything listed here. The main thing is to remember that these methods exist and keep the documentation handy.
Last updated