How do I make it so that by default, 6 div elements are shown on the page, and when a user scrolls to the bottom of the page, six more are loaded?
If you see this ex
Lets assume you have an array of divs each initialized with the document.createElement("div") or similar. Lets assume you have a large array of them.
var myArrayOfDivs = [];//see above
var DivsAdded = 6;//as stated, 6 were already added - index 6 is the 7th element
$(window).scroll(function () {
if ($(window).scrollTop() == $(document).height() - $(window).height()) {
for(int i = 0; i < 6; i++){
if( myArrayOfDivs.length < DivsAdded ) break;
$("#elementToAppendIn").append(myArrayOfDivs[DivsAdded++]);
}
}
});