Find first scrollable parent

后端 未结 8 1397
南方客
南方客 2020-12-02 11:53

I have this situation in which I need to scroll an element into the viewport. The problem is that I don\'t know which element is scrollable. For example, in Portrait the bod

8条回答
  •  猫巷女王i
    2020-12-02 12:57

    This is the way to find what you want.

    document.addEventListener('scroll', (e) => {
        console.log(e.target.scrollingElement.scrollTop);
    })
    

提交回复
热议问题