Infinite scroll plugin keeps appending the same content.
So the jquery plugin I'm using keeps on contentiously appending the same content. I want it to append content from a list of images in my html, but when infinite scroll appends the content when I reach the bottom of the page, it keeps getting appended continuously as I continue scrolling again. I only want it appended once, not multiple times.
Here's the endless scroll plugin:
- $(window).scroll(function () {
- if ($(window).scrollTop() >= $(document).height() - $(window).height() - 10) {
- $(document.body).append($("ul#next").html());
- }
- });
What I've been trying to accomplish:
I need the images within the "next" id to be appended to the "images" id when the user scrolls.
- <ul id="images"> <li>image link</li> </ul>
-
- <ul id="next"> <li>image link</li> </ul>