title: Jquery Next and prev Button work
body: <p>I have done next and prev button functionality. I need to make it so that what happens when I click on the next button, then the same thing happen reversely when clicking on the previous button.</p>
  
  <p>Here I have worked fiddle Link: <a href="http://jsfiddle.net/thilakar/t8v5P/" rel="nofollow">http://jsfiddle.net/thilakar/t8v5P/</a></p>
  
  <pre><code>$(function() {
      //var a = '.mainList';
      var a = 0;
      var b = 2;
      $('#next').click(function() {
          var x = 0;
          var z = $('.mainList').length;
          $('.mainList').each(function() {
              if(a == x){
                  var inner_li = $('#'+a+' ul li').length;
                  for( c=1; c&lt;=inner_li; c++ ){
                      if (c == b) {
                          if ($('#'+a+'_'+c)) {
                              $('#'+a+'_'+c).show();
                          }
                      } else {
                              $('#'+a+'_'+c).hide();
                      }
                      if(b &gt; inner_li) {
                          if (x &lt; z-1) {
                              $('#'+a).hide();
                              a++;
                              $('#'+a).show();
                              b=1;
                          }
                      }
                  }
              }
              x++;
          });
          b++;
      }); 
  
  });
  </code></pre>
  
  <p>Please help me out. </p>