Javascript Scroll Handler not firing

前端 未结 4 1441
攒了一身酷
攒了一身酷 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条回答
  •  佛祖请我去吃肉
    2021-02-12 13:40

    i had the similar issue in my case. This code is correct but was not working because,

    window.addEventListener("scroll", function () {
        myFunc(); 
    }, false);
    

    scroll event wasn't firing. since my body was scrolling instead of documentElement.

    I just removed height: 100% from my body tag and then scroll event started firing.

提交回复
热议问题