簡體   English   中英

jQuery分頁滾動,例如Facebook狀態

[英]Jquery paging scroll such as facebook status

我正在嘗試與本教程一樣進行分頁滾動

 if ($(window).scrollTop() == $(document).height() - $(window).height()) {

它不起作用,它沒有顯示任何動作。 所以我搜索並找到了一種解決方案:

 if($(window).scrollTop() + $(window).height() >= $("#productlist").height()) {

注意:#productlist是我的容器div的ID。

但是,當我這樣做時,每當我滾動鼠標時,頁面就會始終附加數據。 我想要的是,僅在滾動條位於頁面底部(如facebook或twitter頁面加載)時才加載新內容。

誰能告訴我,我該如何解決這個問題?

謝謝。

 $('#yourcontainerId').bind('scroll', function(){

  if($(this).scrollTop() + $(this).innerHeight() >= $(this)[0].scrollHeight)  {
    alert('this will alert only when it reaches the end');
  }
});

這個適用於窗口內的表格/ div

elem[0].scrollHeight - elem.scrollTop() == elem.outerHeight()

var elem = $('#box');
if (elem[0].scrollHeight - elem.scrollTop() == elem.outerHeight()) {
  // We're at the bottom.
}

更多: http : //www.yelotofu.com/2008/10/jquery-how-to-tell-if-youre-scroll-to-bottom/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM