Skip to content

Instantly share code, notes, and snippets.

@andershaig
Created November 17, 2011 16:54
Show Gist options
  • Save andershaig/1373726 to your computer and use it in GitHub Desktop.
Save andershaig/1373726 to your computer and use it in GitHub Desktop.
Load More Items
function mockAjax() {
// The element containing a number of items, some of which you want to hide at first
var cont = $('#deal_cnt');
// Hide all but the first 5.
$("div.deal:gt(4)", cont).hide();
// On-click, load up to 5 more unless there are not left, then hide the button.
$('#load_more_deals').show().live('click', function() {
var hidden_divs = $("div.deal:hidden", cont);
if (hidden_divs.size() <= 5) {
$(this).hide();
}
hidden_divs.slice(0, 5).slideDown();
return false;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment