简体   繁体   中英

jQuery - output scrollLeft when horizontally scrolling

I have a codepen here - https://codepen.io/mt-ttmt/pen/VxYmbG

It's a simple container with a wider container inside that scroll left to right.

How do I out the scrollLeft position of the inner container when scrolling left to right

$(function(){

  $(window).scroll(function(){
    console.log($('.content').scrollLeft());
  })

})

Made some small changes. This seems to be working:

https://codepen.io/anon/pen/WJbRGj

$(window).on('scroll mousewheel', function(){
   console.log($('.content').position().left); 
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM