Unable to call jquery function with scroll on specific div

Short version: It works

$(document).on("click",".Container",function(){})

It does not mean:

$(document).on("scroll",".Container",function(){})

Long version: Sorry, but a code snippet is not possible to publish, as it is a complex interface similar to an application, but I will try to explain this problem to the best of my ability:

  • A responsive mobile website that loads different interfaces based on screen real estate.
  • The smallest interface consists of 3 parts - navigation at the top, search at the bottom and contents in the middle.
  • Content is loaded mainly during use, and not when the page loads.
  • I need to call a function when the content scrolls, both up and down and on the fly, not just past a certain point.
  • I can still scroll, it just doesn't start as an event.
  • , , , , , , , , , .
  • ( ), , hammer.js , .

.

, -

+4
2

@A. @M.Doye -, . , , , .

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

, , , :

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

: https://api.jquery.com/on/

0

Source: https://habr.com/ru/post/1610001/


All Articles