title: Get the value of class in TD JQuery click
body: <p>I want to get the current value from a class from a td in table </p>
  
  <p>script</p>
  
  <pre><code> $(".edit").click(function() {
          // $("#cost").modal();
          id = $('tr').find('td.cost').text();
          alert(id);
      });
  </code></pre>
  
  <p>table</p>
  
  <pre><code> foreach($val as $val)
  &lt;tr&gt;
    &lt;td class="cost"&gt;{{ $val-&gt;cost}}&lt;/td&gt;
    &lt;td&gt;{{$val-&gt;value }} &lt;/td&gt;
    &lt;td&gt;&lt;a class="edit"&gt;&lt;/a&gt;&lt;/td&gt;
  </code></pre>
  
  <p>
      endforeach</p>
  
  <p>I tried </p>
  
  <pre><code> $(".edit").click(function() {
          // $("#cost").modal();
          id = $('tr').find('td.cost').text();
          alert(id);
      });
  </code></pre>
  
  <p>but it will get all values like 12,23,23 (assuming there are three ids fetch from db)</p>