title: Use jquery to find the input inside a div not working as expected
body: <p>I have a table with inputs and I would like to click on a button and then get the values of some inputs. I just don 't understand how to get there in an easy way as my code is returning undefined all the time.</p>
  
  <p>Code for the table:</p>
  
  <pre><code>&lt;table align="center" class='hovertable' width="90%"&gt;
      &lt;tr&gt;
          &lt;div class='line' name='div1'&gt;
              &lt;input id='' class='rpiid' type='hidden' name='rpiid[0]' value='00000000c83de86' /&gt;
              &lt;input id='' class='sensor_id' type='hidden' name='sensor_id[0]' value='1' /&gt;
              &lt;input id='' class='when' type='hidden' name='when[0]' value='2014-02-24 05:00:03' /&gt;
              &lt;td align='center'&gt;2014-02-24&lt;/td&gt;
              &lt;td&gt;
                  &lt;input id='' class='val_displayed' type='text' name='val[0]' value='0366167' /&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;input id='' class='train' type='checkbox' name='train[0]' value='True' /&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;input id='' class='valid' type='checkbox' name='valid[0]' value='True' /&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;button id='0' class='submit_button' type='submit' name='button' value='update'&gt;update&lt;/button&gt;
              &lt;/td&gt;
          &lt;/div&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;div class='line' name='div2'&gt;
              &lt;input id='' class='rpiid' type='hidden' name='rpiid[1]' value='00000000c83de86' /&gt;
              &lt;input id='' class='sensor_id' type='hidden' name='sensor_id[1]' value='1' /&gt;
              &lt;input id='' class='when' type='hidden' name='when[1]' value='2014-02-25 05:00:03' /&gt;
              &lt;td align='center'&gt;2014-02-25&lt;/td&gt;
              &lt;td&gt;
                  &lt;input id='' class='val_displayed' type='text' name='val[1]' value='0366132' /&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;input id='' class='train' type='hidden' name='train[1]' value='False' /&gt;
                  &lt;input id='' class='train' type='checkbox' name='train[1]' value='True' /&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;input id='' class='valid' type='hidden' name='valid[1]' value='False' /&gt;
                  &lt;input id='' class='valid' type='checkbox' name='valid[1]' value='True' /&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;button id='1' class='submit_button' type='submit' name='button' value='update'&gt;update&lt;/button&gt;
              &lt;/td&gt;
          &lt;/div&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>Code for jquery:</p>
  
  <pre><code>$(document).ready(function () {
      $('.submit_button').click(function () {
          var val = $(this).closest('.when').attr('value');
          alert('the value is ' + val);
          return false;
      });
  });
  </code></pre>
  
  <p>The jsfiddle:
  <a href="http://jsfiddle.net/starcraft04/BLCJ5/10/" rel="nofollow">http://jsfiddle.net/starcraft04/BLCJ5/10/</a></p>
  
  <p>Thanks if you can help,</p>
  
  <p>John.</p>