i wanted to get the scroll method and load somthing while scrolling happens .
its not working properly
maybe because my elements are being added to the page dynamically.
however i see the existance of the elements but its not working programmatically.
and while i add these methods into my chrome’s console then it start to work.
idk how to solve it.
$(document).ready(function () {
////First Method
$(".convHistory").on('scroll', function () {
console.log('Event Fired');
});
////Second Method
$(".convHistory").bind('scroll', function () {
console.log('Event worked');
});
////Third Method
document.addEventListener('scroll', function (event) {
if (event.target.className.includes("convHistory")) {
console.log('scrolling', event.target);
}
}, true /*Capture event*/);
//forth method
$('.convHistory').scroll(function () {
console.log('Event worked');
});
});
2
Answers
As your elements are dynamic, bind events for dynamic elements like this:-
As you already said, the elements are binding dynamically, you have to do something like below
then after that