title: Jquery find nearest matching element
body: <p>I have a series of rows with columns and I want to select the value of an <code>input</code> field that is in a previous column to the <code>input</code> field (price input) that I am calling a function on when a key is released.</p>
  
  <p>I have tried:</p>
  
  <pre><code>quantity = $(this).parent().parent().children().val() ;
  quantity = $(this).parent().parent().children().closest('.inputQty', this).val() ;
  </code></pre>
  
  <p>But neither work.</p>
  
  <p>An example of the DOM:</p>
  
  <pre><code>&lt;div class="row"&gt;
      &lt;div class="column"&gt;&lt;input class="inputQty" id="quantity0" /&gt;&lt;/div&gt;
      &lt;div class="column"&gt;&lt;input class="someOther" id="Other0" /&gt;&lt;/div&gt;
      &lt;div class="column"&gt;
          &lt;div class="cSelect"&gt;
              &lt;select id="currency0"&gt;&lt;option&gt;£&lt;/option&gt;&lt;/select&gt;
              &lt;input class="price" id="price0" /&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>