How do I get the max value of scrollLeft?

前端 未结 8 605
夕颜
夕颜 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:46

    var scrollContainer = $('.b-partners .b-partners__inner');
    var maxScrollLeft = $(scrollContainer)[0].scrollWidth - $(scrollContainer).width();
    console.log(maxScrollLeft);
    

提交回复
热议问题