は、特定のdiv
を使用して扱うinnerHeight()
機能とscrollHeight
$('.scroll').scroll(function() {
var lastItemHeight = $(this).children().last().height();
if ($(this).scrollTop() >= $(this)[0].scrollHeight - $(this).innerHeight() - lastItemHeight) {
console.log($(this).scrollTop() + '-' + $(this).innerHeight() + '-' + $(this)[0].scrollHeight + '-' + lastItemHeight)
}
});
$('.scroll').scroll(function() {
var lastItemHeight = $(this).children().last().height();
if ($(this).scrollTop() >= $(this)[0].scrollHeight - $(this).innerHeight() - lastItemHeight) {
console.log($(this).scrollTop() + '-' + $(this).innerHeight() + '-' + $(this)[0].scrollHeight + '-' + lastItemHeight)
}
});
.scroll {
height: 200px;
width: 100%;
overflow: auto;
}
.child {
height: 50px;
width: 100%;
overflow: auto;
background: red;
border: solid 1px black;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="scroll">
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
</div>
を使用して、そのdiv要素にスクロールするが、.scrollか、私はrowHeightのクラス名はそれに10アイテムを持っている持っているし、私は、9番目の項目がスクロールされたときに、トリガーnewAjaxCallfunctionを必要とします。 –
最後の要素の高さを使用して、最後の要素の開始位置を計算します。私は答えを更新しました。あなたが好きな人のために役立つように、回答を受け入れてください。 – jafarbtech
.scrollは何ですか。私のdivはクラス= "col-lg-12 col-md-12 col-no-padding hidden-xs rowHeight"のみであり、prodheightクラスの9itemにスクロールすると10回ループしてnewAjaxCallfunctionを起動する必要があります)。 –