jQuery > Manipulations methods

.scrollTop() - Get & set vertical scroll position in jQuery

How to get and set the vertical scroll position of an element in jQuery?


To get and set the current vertical position of an element, scrollTop() method can be used.

 <script>
     alert($("#divScroll").scrollTop());
     $("#divScroll").scrollTop("100");
  </script>

Above code snippet will first alert the scroll top position of the element whose id is “divScroll” and then move its vertical scroll bar position to 100.

 Views: 17684 | Post Order: 57



Write for us






Hosting Recommendations