infinite scroll css in div code example
Example: infinite scroll within a div
<script>
$(function(){
$(window).scroll(function () {
var $div = $(".scrollme");
var divPlacement = parseInt($div.offset().top + parseInt($div.height()));
var screenBottom = $(this).scrollTop() + parseInt($(window).height());
divPlacement -= 300;
if(divPlacement <= screenBottom) {
$('.scrollme').append('<p style="height: 300px; background-color: '+getRandomColor()+'"></p>');
}
});
});
function getRandomColor() {
var letters = '0123456789ABCDEF'.split('');
var color = '#';
for (var i = 0; i < 6; i++ ) {
color += letters[Math.floor(Math.random() * 16)];
}
return color;
}
</script>