title: Display button when hover over certain row in table
body: <p>I am trying to make a button show up when I mouseover a certain row. The $index variable is the total number of rows in the table. The "#r"+a.toString() variable refers to the id of the table row and "#b"+a.toString() refers to the button of the row that I want to be displayed when I hover over a certain row of the table. Currently it displays the button in the last row whenever I mouseover any row.</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      $(document).ready(function (){
          for(a=1; a &lt;= &lt;?php echo $index; ?&gt;; a++){
          var button = $("#b"+a.toString());
          $("#r"+a.toString()+" td").mouseover(function(){
              button.css({"visibility": "visible"});
          });
          $("tr td").mouseout(function(){
              button.css({"visibility": "hidden"});
          });
      }
      });
  &lt;/script&gt;
  
  
  
  &lt;table class="table table-striped table-bordered table-condensed table-hover"&gt;
                      &lt;thead&gt;
                          &lt;tr&gt; 
                              &lt;th&gt;Item&lt;/th&gt;
                              &lt;th&gt;Quantity&lt;/th&gt;
                              &lt;th&gt;Price&lt;/th&gt;
                          &lt;/tr&gt;
                      &lt;/thead&gt;
                      &lt;?php 
                          $item_array;
                          $index = 0;
                          $index_2 = 1;
                          $r = "r";
                          $b="b";
                          foreach ($item_array as $id_array){ ?&gt;
  
                              &lt;tr id="&lt;?php echo $r.$index_2; ?&gt;"&gt;
                               &lt;td&gt;&lt;?php echo $item_array[$index] ?&gt;&lt;/td&gt;
                                  &lt;td&gt; &lt;?php echo $quantity_array[$index] ?&gt;&lt;/td&gt;
                 &lt;td&gt;   
                          &lt;form method='POST' action='edit.php'&gt;
                              &lt;?php echo $price_array[$index];?&gt;
                              &lt;button id="&lt;?php echo $b.$index_2; ?&gt;" type="button" style="float:right; visibility:hidden; align-content:right;" class="btn btn-sm btn-warning"&gt;Edit&lt;/button&gt;
                          &lt;/form&gt;
                      &lt;/td&gt;&lt;?php
                          $index++;
                          $index_2++;
  
                          echo "&lt;/tr&gt;";
                          } ?&gt;
  
                  &lt;/table&gt;
  </code></pre>