Javascript Scroll Handler not firing

前端 未结 4 1420
攒了一身酷
攒了一身酷 2021-02-12 12:56

All I\'m trying to do is to call a function when a DIV is scrolled.For simplicity sake Im not specifying anything else. Also I am only looking at DOM compliant brow

4条回答
  •  闹比i
    闹比i (楼主)
    2021-02-12 13:30

    I have similar issue. But in my case, I have a height: 100% on my body. Since, I just wanted to apply the scroll event in a special div only.

    Then, this fixed the issue:

    document.querySelector('#myDiv').addEventListener('scroll', () => { console.log('scroll event fired!') });

提交回复
热议问题