I am a newbie in jQuery. Basically, I need to write a query for lazy loading on a page. I found this post: Detecting when user scrolls to bottom of div with jQuery and I wanted to try the query from there:
jQuery(function($) {
$('#pics').bind('scroll', function() {
if($(this).scrollTop() +
$(this).innerHeight() >= this.scrollHeight) {
alert('end reached');
}
});
});
However, for me it didnt work, and I decided to create a simple (very simple) page and to test if the script will work there. Here is my code:
jQuery(function($) {
$('#pics').bind('scroll', function() {
if($(this).scrollTop() +
$(this).innerHeight() >= this.scrollHeight) {
alert('end reached');
}
})
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<h1>YEAH SANDWICHES</h1>
<div id="pics">
<img src="http://placehold.it/304x228" alt="" /><br />
<img src="http://placehold.it/304x228" alt="" /><br />
<img src="http://placehold.it/304x228" alt="" /><br />
<img src="http://placehold.it/304x228" alt="" /><br />
<img src="http://placehold.it/304x228" alt="" /><br />
<img src="http://placehold.it/304x228" alt="" /><br />
<img src="http://placehold.it/304x228" alt="" /><br />
<img src="http://placehold.it/304x228" alt="" /><br />
<img src="http://placehold.it/304x228" alt="" /><br />
<img src="http://placehold.it/304x228" alt="" /><br />
<img src="http://placehold.it/304x228" alt="" /><br />
<img src="http://placehold.it/304x228" alt="" /><br />
<img src="http://placehold.it/304x228" alt="" /><br />
<img src="http://placehold.it/304x228" alt="" /><br />
<img src="http://placehold.it/304x228" alt="" /><br />
</div>
However, all images are pre-loaded and the jQuery script doesn't work at all. What am I doing wrong?
`. Please learn `HTML`. – Praveen Kumar Purushothaman Jun 18 '15 at 09:52