Tuesday, 15 June 2010

jquery - Scroll a div's scroll bar all the way to the right with javascript -



jquery - Scroll a div's scroll bar all the way to the right with javascript -

this question duplicate of jquery scrollright?

i have div lot of content (width-wise) , overflow:auto, have scroll bar @ bottom. starts scrolled left: there way scroll way on right, using jquery/native js?

even if there's way in css (which preferable) need in js, because other stuff happens in table first in js (using jquery plugin datatables specific) in dom ready block, code needs run after that.

i thought simple i've not managed google useful.

thanks! max

here's how did - might consider bit hacky.

in sample below, "#test" div 100px width , overflow: auto.

$("#test").css("overflow","none"); $("#test").css("width","none"); var width = $("#test").width(); $("#test").css("overflow","auto"); $("#test").css("width","100px"); $("#test").animate({scrollleft: width}, 100);

here i'm getting rid of width , overflow css properties work out true width of content is. i'm putting css properties on , scrolling width.

here's jsfiddle: http://jsfiddle.net/drefh/

javascript jquery scrollbar

No comments:

Post a Comment