title: Jquery, ajax: Clicking on a button and getting the value of the cell next to it on the same row
body: <p>I have been reading the tutorials on JS and it occurred to me that I wanted the following:</p>
  
  <p>Say a table with 3 cols and several rows.</p>
  
  <p>First col an int value, second colon a yes green button and third a red button</p>
  
  <p>On clicking on the button, it should get as value that of the cells of the first colum (I am doing a polling table).</p>
  
  <p>UPDATE IV:</p>
  
  <p>This works finally, thanks to Adeneo and Anthony Grist. Thank you for your patience and help.</p>
  
  <p>Here it is:</p>
  
  <pre><code>&lt;script&gt;
      $(document).ready(function(){
  
          $('.oui').click(function(){
              var valor = $(this).closest('tr').find('td:first').text();
              $(this).attr('value', valor);
          });
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>HTML:</p>
  
  <pre><code>&lt;div class="container"&gt;
      &lt;!-- Example row of columns --&gt;
      &lt;div class="row"&gt;
          &lt;div class="col-lg-12"&gt;
  
              &lt;table class="table table-striped table-bordered"&gt;
                  &lt;thead&gt;
                      &lt;tr&gt;
                          &lt;th&gt;Prenom&lt;/th&gt;
                          &lt;th&gt;Nom&lt;/th&gt;
                          &lt;th&gt;Tantieme&lt;/th&gt;
                          &lt;th&gt;Oui&lt;/th&gt;    
                          &lt;th&gt;Non&lt;/th&gt;
                          &lt;th&gt;Abstention&lt;/th&gt;    
                          &lt;th&gt;Absent&lt;/th&gt;
                      &lt;/tr&gt;
                  &lt;/thead&gt;
                  &lt;tbody&gt;
                  @foreach ($polls as $vote)
                      &lt;tr&gt;
                          &lt;td&gt;{{ $vote-&gt;prenom}}&lt;/td&gt;
                          &lt;td&gt;{{ $vote-&gt;nom}}&lt;/td&gt;
                          &lt;td&gt;{{ $vote-&gt;tantieme }}&lt;/td&gt;
                          &lt;td&gt;&lt;button type="button" id="oui" class="btn btn-success"&gt;VOTE OUI&lt;/button&gt;&lt;/td&gt;    
                          &lt;td&gt;&lt;button type="button" id="non" class="btn btn-danger"&gt;VOTE NON&lt;/button&gt;&lt;/td&gt;
                          &lt;td&gt;&lt;button type="button" class="btn btn-info"&gt;ABSTENTION&lt;/button&gt;&lt;/td&gt;    
                          &lt;td&gt;&lt;button type="button" id="default" value = "230" class="btn btn-default"&gt;ABSENT&lt;/button&gt;&lt;/td&gt;
                      &lt;/tr&gt;
                  @endforeach
                  &lt;/tbody&gt;
              &lt;/table&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>