views:

60

answers:

1

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?

+1  A: 

perhaps you can number them in advance,

ul id = or li id =, and the skip 1 or 5 each time a click is passed

( should be faster aswell )

FrankBr