Last active
June 3, 2016 08:49
-
-
Save faisalhmohd/ced38e98655148738c2efa563fb2a831 to your computer and use it in GitHub Desktop.
Displaying N posts and load more button
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var postSize = $(".posts div").size(); | |
var postLimit = 8; | |
var postDisplay = 8; | |
var endPosts = false; | |
$('.posts div:lt('+postDisplay+')').show(); | |
$('#loadmore').click(function () { | |
if (postDisplay + postLimit <= postSize) { | |
postDisplay += postLimit; | |
} | |
else { | |
postDisplay = postSize; | |
endPosts = true; | |
} | |
$('.posts div:lt('+postDisplay+')').show(); | |
if (endPosts) { | |
$('#loadmore').hide(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment