2
所以這裏是我的網頁發現哪些元素(DIV)已被證明在一個頁面滾動條
<Style>.item{ width :200px ; height:200px ; background-color:red ; float:right ; margin : 10px}</style>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
這裏是完整的代碼
http://jsfiddle.net/gup3o1ap/1/
,你可以看到有頁面上有很多div.item和頁面有一個大滾動條,我想知道哪些.item已被用戶看到,所以基本上我需要知道頁面上可見的最後一個項目(.items之前有已經顯示)
這樣我就可以計算出,當滾動到達的頁面
$(window).scroll(function() {
if($(window).scrollTop() + $(window).height() > $(document).height() - 200) {
console.log('at the end');
}
});
結束,但我不知道我怎樣才能找到哪個元素是頁面
你的小提琴似乎在爲我工作:http://jsfiddle.net/hyuf929k/它在底部時發出警報? –
@SimonStaton我想知道哪個元素是頁面上顯示的最後一個元素,而不是當滾動到達頁面底部時 – max