title: display div inside loop using next and prev button
body: <p>I am trying to show each div data using next and prev button. how to do it using jQuery?
  These are my codes.</p>
  
  <p>PHP code:</p>
  
  <pre><code>&lt;div class="divs"&gt;
  &lt;?php
    for($i=1; $i&lt;=10;$i++){
    ?&gt;&lt;div class="cls&lt;?php echo $i; ?&gt;"&gt;&lt;?php echo $i; ?&gt; &lt;/div&gt;
    &lt;?php
    }
  ?&gt;
   &lt;/div&gt;
   &lt;a id="next"&gt;next&lt;/a&gt;
   &lt;a id="prev"&gt;prev&lt;/a&gt;
  </code></pre>
  
  <p>JavaScript code:</p>
  
  <pre><code>$(".divs div").each(function(e) {
          if (e != 0)
              $(this).hide();
      });
  
      $("#next").click(function(){
          if ($(".divs div:visible").next().length != 0)
              $(".divs div:visible").next().show().prev().hide();
          else {
              $(".divs div:visible").hide();
              $(".divs div:first").show();
          }
          return false;
      });
  </code></pre>