Run javascript function when div is scrolled to

This question already has an answer here:

  • jQuery event to trigger action when a div is made visible 21 answers

  • You can achieve it using Jquery.

    $( '#yourdiv').scroll(function() {
       if ( $(this)[0].scrollHeight - $(this).scrollTop() <= $(this).outerHeight()){
           //ajax method for getting your data
           //append response data to your div
        } 
    });
    

    Refer this for How to implement ajax using jquery

    链接地址: http://www.djcxy.com/p/83378.html

    上一篇: jQuery中的onHide()类型事件

    下一篇: 当div滚动到时运行javascript函数