Get div tag scroll position using JavaScript

后端 未结 2 2056
慢半拍i
慢半拍i 2021-01-03 18:29

How do I get the amount of scroll in a div tag using JavaScript? Please provide me with an example.

I don\'t want to use jQuery, only JavaScript.

2条回答
  •  Happy的楠姐
    2021-01-03 19:17

    you use the scrollTop attribute

    var position = document.getElementById('id').scrollTop;
    

提交回复
热议问题