Setting a scrollbar position Setting a scrollbar position javascript javascript

Setting a scrollbar position


If you want to go the non-jQuery way, use the containing table's scrollTop property.

Lets assume you can easily identify the row you want to scroll to using an ID, along with the containing <div />. Use the offsetTop of the element you want to scroll to.

var container = document.getElementById('myContainingDiv');var rowToScrollTo = document.getElementById('myRow');container.scrollTop = rowToScrollTo.offsetTop;


You can use this:

$('a').on('click', function(e){  var t = this.id.substring(1);  e.preventDefault();  var target= $(".section")[t] ;  var offset = $( target ).offset();  $('html, body').stop().animate({    scrollTop: offset.top  }, 1000);});

Also, you could check this example on jsfiddle .


Using Jquery:

'.scroll-table' is the class name used for scroll-able part

1.First go to the initial position

$('.scroll-table').scrollTop(0);

2.Below line calculates the scroll difference between the tables top position and the row to which we have scroll

$('.scroll-table').scrollTop($('#myrowid').position().top-$('.scroll-table').position().top);