Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jeffersonswartz/83f3e0521addf144ffff to your computer and use it in GitHub Desktop.
Save jeffersonswartz/83f3e0521addf144ffff to your computer and use it in GitHub Desktop.
Simple jQuery Infinite Scroll
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Simple jQuery Infinite Scroll</title>
</head>
<body>
<h1>One</h1>
<br />
<h1>Two</h1>
<br />
<h1>Three</h1>
<br />
<h1>Four</h1>
<br />
<h1>Five</h1>
<br />
<h1>Six</h1>
<br />
<h1>Seven</h1>
<br />
<h1>Eight</h1>
<br />
<h1>Nine</h1>
<br />
<h1>Ten</h1>
<br />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script>
$(function() {
$(window).scroll(function () {
var theWindow = $(this);
var theContainer = $('body');
var tweak = 10;
if ( theWindow.scrollTop() >= theContainer.height() - theWindow.height() - tweak ) {
theContainer.append('<h1>One More</h1><br />');
}
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment