.on()-Function does not rebuild DOM

2019-09-01 01:45发布

I am trying to automatically click a link when I scroll down to the bottom. It then loads some content with another link that does the same. This works perfectly for the first time but when the next link is loaded via AJAX it does not get clicked anymore. I assume it has something to do with the DOM not getting rebuild. Thank you.

$(window).on('scroll', function() {         
       timeout = window.setTimeout( check, 100);
    });

function check(){
    if (($(window).scrollTop() + $(window).height()) >= ($('body').height() * 0.9)) {
        alert('Call me!');
        $('.selector').click(); 
     }
}

0条回答
登录 后发表回答