Created
November 17, 2011 16:54
-
-
Save andershaig/1373726 to your computer and use it in GitHub Desktop.
Load More Items
This file contains hidden or 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
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