title: jquery pagination through multiple ul lists
body: <p>I can't get this script to work well. Can someone help me? First, I would like to make it that I can use it for multiple <code>&lt;div&gt;</code> and  <code>&lt;ul&gt;</code> elements.
  One other thing, I would like to make it so that if I have more than 5 <code>&lt;li&gt;</code> elements it appends a "next" button and then on page 2, it appends "prev" and "next" buttons. Also, if on the last page "next" button shouldn't be seen.
  Here is my current code:</p>
  
  <pre><code> $('div').each(function(){
      $(this).append('&lt;a class="prev"&gt;prev&lt;/a&gt; | &lt;a class="next"&gt;next&lt;/a&gt;');
      $(this).find('ul li:gt(4)').hide();
  
      $(this).find('.next').click(function() {
          var last = $('ul').children('li:visible:last');
          last.nextAll(':lt(5)').show();
          last.next().prevAll().hide();
      });
  
       $(this).find('.prev').click(function() {
          var first = $('ul').children('li:visible:first');
          first.prevAll(':lt(5)').show();
          first.prev().nextAll().hide()
      });
  
  });
  </code></pre>
  
  <p>Working example <a href="http://jsfiddle.net/e6sP7/3/" rel="nofollow">http://jsfiddle.net/e6sP7/3/</a> </p>