How do I get the max value of scrollLeft?

前端 未结 8 614
夕颜
夕颜 2020-12-04 21:28

Okay I\'m using jQuery and currently getting max value of scrollbar doing this:

var $body = $(\'body\');
$body.scrollLeft(99999); // will give me the max val         


        
8条回答
  •  不知归路
    2020-12-04 21:43

    I think that you could use something like this:

    this.children().width()*(this.children().length+1)-this.width()-10;
    

    The previous line of code is going to get the width of one of the children and multiply this with by the number of chilren, finally you need to substract the width of the element minus an offteset

提交回复
热议问题