Can't delegate scroll event using jQuery

前端 未结 2 1327
灰色年华
灰色年华 2021-01-26 14:01

I\'m trying to use jQuery to fire an event on scroll on a particular class of elements, like so:

$(\'body\').on(\'scroll\', \'.overflow\', function() { do stuff;         


        
2条回答
  •  走了就别回头了
    2021-01-26 14:33

    According to W3, the scroll event doesn't bubble.

    Since event delegation relies on the event bubbling to the element you've attached the handler to, you won't be able to use delegation.

提交回复
热议问题