title: JQuery function for multiple button event with different Id
body: <p><strong>This below code create multiple page button.</strong></p>
  
  <pre><code>&lt;?php
  for($i=1; $i&lt;=$this-&gt;total_pages; $i++)
  {
    echo "&lt;button class='btn page' id='next".$i."' value='".$i."'&gt;".$i."&lt;/button&gt;";
  }
  ?&gt;
  </code></pre>
  
  <p><strong>here below the view of page is show like</strong> </p>
  
  <pre><code>1 2 3 4 5 6 ........//I dont know how many pages
  </code></pre>
  
  <p><strong>Here in below code i want to catch only that id with value which is trigger by user. I don't know the id name.</strong></p>
  
  <pre><code>&lt;script&gt;
      $( document ).ready(function() {
       $('button[id^="next"]').on('click', function() {
          var page = ($(this).attr('value'));
          $.ajax({
            type: "GET",
            url: 'index.php?act=product',
            data: ({page:page}),
            success: function(data) {
              var my_rows = $(data).find('tbody').html();
              $('tbody').append(my_rows);
            }
          });
          $(this).hide();
       });
      });
  &lt;/script&gt;
  </code></pre>
  
  <blockquote>
    <p>My question is that why my script is append rows wrong after click on any page. when i click on 2 it appends 10 rows. after then i click on 3 it appends 6 rows after then i click on 4 it appends 1 row. why?</p>
  </blockquote>
  
  <p><strong>My controller page is below</strong></p>
  
  <pre><code>&lt;?php
  include "model/login_class.php";
  include "view/template/product_class.php";
  $tplLogin=new LoginTpl();
  $sqlLogin=new sqlLogin();
  //echo $_GET['page']; exit;
  $total_results = $sqlLogin-&gt;totalproduct();
  $per_page = 5;
  $total_pages = ceil($total_results / $per_page);
  $tplLogin-&gt;total_pages = $total_pages;
  if (isset($_GET['page'])) {
      $show_page = $_GET['page']; //current page
      if ($show_page &gt; 0 &amp;&amp; $show_page &lt;= $total_pages) {
          $start = ($show_page - 1) * $per_page;
          $end = $start + $per_page;
      } else {
          // error - show first set of results
          $start = 0;              
          $end = $per_page;
      }
  } else {
      // if page isn't set, show first set of results
      $start = 0;
      $end = $per_page;
  }
  // display pagination
  $sqlLogin-&gt;start = $start;
  $sqlLogin-&gt;end = $end;
  $tplLogin-&gt;products = $sqlLogin-&gt;product();
  $tplLogin-&gt;product();
  ?&gt;
  </code></pre>