Saturday, January 29, 2011

set scrooll of div for selected item

We have a div which contains 200 radio buttons. we fixed the height of div and set the vertical scroll now we want that scroll position should automatically set according to selected item.

For this we have to find the selected vaue and get its offsetTop value and set this value to div.ScroolTop.

Code is follwoing :

var container = document.getElementById('hhhjh');
var rowToScrollTo = document.getElementById('setID7');
container.scrollTop = rowToScrollTo.offsetTop;

No comments: