The automatic click on the download is larger, but the automatic click only starts after the first click manually

I tried to add an automatic click on the link "Download more", but after downloading manually automatically downloads. I am stuck on this. If anyone knows a solution, please help.

 <?php if( $next_link !== false ):?>
        <div class="sp-load-more text-center"  >
         <a href='#'  title="Load more result" data-url="<?php echo $next_link;?>" onclick="return doko.BuSfw16AlL(this, {container: '#search-results', rc : '.sp-load-more'})">
            <span id="l-more" > Load More <i  class="fa fa-angle-down fa-lg"></i>  </span>
          </a>
            </div>

<?php else:?>
        <div class="panel sp-box sp-load-more">
                <div class="panel-body">
                <span>-- End of Result --</span> 
                </div>
        </div>
<?php endif; ?>

<script >
$(function(){ //on document ready
    $(document).scroll(function (e) { //bind scroll event

        var intBottomMargin = 300; //Pixels from bottom when script should trigger

        //if less than intBottomMargin px from bottom
        if ($(window).scrollTop() >= $(document).height() - $(window).height() - intBottomMargin) {
            $("#l-more").click(); //trigger click
        }

    });
});
</script>
+4
source share
1 answer

You need to use the tag id <a>, so you need to change:

    <a href='#' id="the_id"  title=....

and

      $("#the_id").click(); //trigger click
0
source

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


All Articles