Skip to content Skip to sidebar Skip to footer

Can't Trigger A Jquery Function With Scroll On A Particular Div

Short version: This works $(document).on('click','.Container',function(){}) This does not: $(document).on('scroll','.Container',function(){}) Long version: I'm sorry but posting

Solution 1:

I think it's because the scroll event doesn't bubble and you are adding the listener as delegated, you should add it directly:

$('.Container').on('scroll',function(){});

More info about this in: https://api.jquery.com/on/


Solution 2:

With help from @A. Wolf and @M.Doye I found something that works. While it doesn't help understand what was wrong at least its working.

document.addEventListener('scroll',function(event){
    if(event.target.className==='Container'){
        insert magic spell here
    }
},true);

Post a Comment for "Can't Trigger A Jquery Function With Scroll On A Particular Div"