I have the following code:
var from = 0, step = 5;
function showNext(list) {
list
.find('li').hide().end()
.find('li:lt(' + (from + step) + '):not(li:lt(' + from + '))')
.show();
from += step;
}
// show initial set
showNext($('ul'));
// clicking on the 'more' link:
$('#more').click(function(e) {
e.preventDefault();
showNext($('ul'));
});
This only shows 5 next list elements. But what if I want to navigate to the 5 previous items by clicking a «Previous» link?