I have a div element with position absolute and overflow scroll like this:
<style>
.sevencov {
position: absolute;
width: 61.333%;
left: 16.667%;
top: 46px;
bottom: 0;
right: 0;
overflow: auto;
}
</style>
<div class="sevencov">
<a id="load-more" class="load-more" title="Load More" onclick="myFunction()"></a>
</div>
I want to fire the load more button at a certain % of the div on scroll, using jQuery I tried this:
$(function () {
var prevHeight = $('.sevencov').height();
$('.sevencov').scroll(function () {
var curHeight = $(this).height();
if ($(this).scrollTop() > ($(document).height() - curHeight)*44) {
$('#load-more').click();
}
});
});
But the problem is that it fires multiple times because the height of my div sevencov
is always the same and I'm not able to find a solution, what am I doing wrong?