开发者

How to know the end of scrolling event for a <div> tag

I need to trigger a function if scroll end has reached for a div tag ..

    $("#page").bind("scroll",function(e){ //page is the ID of the div im scrolling
          if (document.body.scrollHeight - $(this).scrollTop()  <= $(this).height())
          {
             //the code here is called every time the s开发者_如何学运维croll is happened i want to call     
             //this only when the scroll reaches the end of div
          }   
    });


$("#page").scroll( function() {
  if($(this)[0].scrollHeight - $(this).scrollTop() == $(this).outerHeight()) {
   // what you want to do ...
  }
});


$("#page").bind("scroll",function(e){ //page is the ID of the div im scrolling

      if ( ( $(this).height() + $(this).scrollTop() ) => $(this).innerHeight() )
      {
         //Test it first without padding. Then see if you need to tweak the left part of the condition
      }   
});


Following code worked for me

$("#page").scroll( function() {
    if($(this).scrollTop() >= ($(this)[0].scrollHeight - $(this).outerHeight())) 
    {
        alert("End here");
    }
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜