2011-04-02 72 views

回答

1

如果您的需要是檢測用戶是在最低部分,下面的代碼將工作

<div class="test">not at bottom</div> 
<div class="test">not at bottom</div> 
<div class="test">not at bottom</div> 
.... 
<div class="test">not at bottom</div> 
<div class="test">not at bottom</div> 

<div id="placeholder">placeholder</div> 


$(window).scroll(function check(){ 
    var top = $("#placeholder").offset().top; 
    if($(window).scrollTop() + jQuery(window).height() > top){ 
     $(".test").each(function(){$(this).html("at bottom")}); 
    }else{ 
     $(".test").each(function(){$(this).html("not at bottom")}); 
    } 
}); 

你可以在jsFiddle看到。