title: Jquery only activate current row button
body: <p>I have 2 buttons to expand and shrink a subtable at a specific row. The buttons will change from a + to a - when clicked. Currently when I click on a button, the correct row shows up. However, all the buttons turn into a -. May I know how I can limit the button to the current row only.</p>
  
  <p>This is my code</p>
  
  
  
  <pre><code>$('.expandlink').on('click', function () {
      var curr_row = $(this).parent().parent('tr').attr('data-id');
  
      $(".subtable").each(function () { //loop through each row
          if ($("[type='hidden']", this).val() == curr_row) {
              $(this).show();
              $('.expandlink').hide();
              $('.shrinklink').show();
          }
      });
  });
  
  $('.shrinklink').on('click', function () {
      var curr_row = $(this).parent().parent('tr').attr('data-id');
  
      $(".subtable").each(function () {
          if ($("[type='hidden']", this).val() == curr_row) {
              $(this).hide();
              $('.shrinklink').hide();
              $('.expandlink').show();
          }
      });
  });
  </code></pre>
  
  
  
  <pre><code>&lt;tbody&gt;
  &lt;?php $offset = $this-&gt;uri-&gt;segment(4,0)+1; ?&gt;
  &lt;?php foreach($user as $row): ?&gt;
  &lt;tr data-id="&lt;?php echo $row-&gt;id; ?&gt;"&gt;
  &lt;td&gt;&lt;?php echo $offset++; ?&gt;&lt;/td&gt;
  &lt;td&gt;&lt;?php echo $row-&gt;company; ?&gt;&lt;/td&gt;
  &lt;td&gt;&lt;?php echo $row-&gt;firstname; ?&gt;&lt;/td&gt;
  &lt;td&gt;&lt;?php echo $row-&gt;lastname; ?&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type="hidden" class="id" name="id" value="&lt;?php echo $row-&gt;id; ? &gt;"/&gt;&lt;input type="button" class="expandlink" value="+"/&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type="hidden" class="id" name="id" value="&lt;?php echo $row-&gt;id; ?&gt;"/&gt;&lt;input type="button" class="shrinklink" value="-"/&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type="hidden" class="id" name="id" value="&lt;?php echo $row-&gt;id; ?&gt;"/&gt;&lt;input type="hidden" name="company" value="&lt;?php echo $row-&gt;id; ?&gt;"/&gt;&lt;input type="hidden" name="set" value="edit"/&gt;&lt;input type="button" class="editlink" value="Edit"/&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type="hidden" class="id" name="id" value="&lt;?php echo $row-&gt;id; ?&gt;"/&gt; &lt;input type="hidden" name="company" value="&lt;?php echo $row-&gt;id; ?&gt;"/&gt;&lt;input type="hidden" name="set" value="delete"/&gt;&lt;input type="button" class="deletelink"  value="Delete"/&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr class="subtable"&gt;
      &lt;td&gt;&lt;input type="hidden" value="&lt;?php echo $row-&gt;id; ?&gt;"/&gt;&lt;/td&gt;
      &lt;td&gt;&lt;?php echo $row-&gt;company; ?&gt;&lt;/td&gt;
      &lt;td&gt;&lt;?php echo $row-&gt;firstname; ?&gt;&lt;/td&gt;
      &lt;td&gt;&lt;?php echo $row-&gt;lastname; ?&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;?php endforeach; ?&gt;
  &lt;/tbody&gt;
  </code></pre>