title: how to stop .next() going off list of li's
body: <p>i am working on a gallery where i navigate previous and next list items using arrow keys. now using <code>.next()</code> and <code>.prev()</code> i am able to navigate really nice but the problem starts when the last List Item is there and the jquery goes to <code>.Next()</code>.</p>
  
  <p>How can i stop  a process that it won't go after last li Item.</p>
  
  <p>i mean the <code>next()</code> function dosent apply after last Li.
  Here is my sample code</p>
  
  <pre><code>  var ul = $('#thumbsList');
  ul.find('li').first().addClass('current');
  </code></pre>
  
  <p>This one adds a class.</p>
  
  <pre><code>    $(document).ready(function () {
      $('#nextHandler').click(function () {
  
          var nextListItem = ul.find('li.current').next();
  
          ul.find('li.current').removeClass('current');
          nextListItem.addClass('current');
          var imagePath = ul.find('li.current').children('img').data("fullsrc");
          // Setting Image Path to Current Next Image path
          $("#fullImagePlaceholder").attr("src", imagePath);
  
  
      });
  });
  </code></pre>
  
  <p>This does the job.
  <strong>But the problem starts when it jumps of the last LI.</strong> How to stop it.
  thanks.</p>