Can't delegate scroll event using jQuery

前端 未结 2 1351
灰色年华
灰色年华 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:25

    Use "mousewheel" instead,
    make sure #contents is on the main html file.

        $("#contents").on('mousewheel',function(e) {
        if(e.originalEvent.wheelDelta /120 > 0) {
             //do something to the loaded elements
         } else {
            //do something to the loaded elements
         }
    });
    

提交回复
热议问题