jQuery function scrollTop()gives the distance between the top of the object and the topmost portion of the content of the object currently visible and can be used to determine the amount you have scrolled.
e.g: $(window).scrollTop() will give you the amount you have scrolled from the topmost part of the page.
This can be very useful for adding navigation features. For instance,in some sites you might have seen a link “Scroll To Top” which will take you to top of the page and that the link is visible only if you have scrolled down atleast one page.
The following code snippet using jQuery function implements this feature:
// Window Scroll event.
// If the scroll amount is larger than the window height then show "Scroll To Top" link.
if ($(window).scrollTop() > $(window).height())
$('#scrollToTop').fadeIn('slow'); // Show "Scroll To Top" link.
$('#scrollToTop').fadeOut('slow'); // Hide "Scroll To Top" link.