title: jQuery add value to closest element in table
body: <p>i have a problem. I need to add different values in 2 same classes.
  I need to do:
  1. When i change dropdown from Test 1,2,3 and 4 the value in text field must be 10, 15 or...values from text input (in real system they are hidden) with id = price-1,2,3 and 4.
  2. When i change dropdown from Test 5,6,7, and 8 the values from first dropdown must not change.</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;input type="text" value="10" id="price-1" size="2" /&gt;
  &lt;input type="text" value="15" id="price-2" size="2"/&gt;
  &lt;input type="text" value="20" id="price-3" size="2"/&gt;
  &lt;input type="text" value="25" id="price-4" size="2"/&gt;
  &lt;table&gt;
  &lt;tr&gt;
      &lt;td&gt;
          &lt;select class="drop"&gt;
              &lt;option value="1"&gt;Test 1&lt;/option&gt;
              &lt;option value="2"&gt;Test 2&lt;/option&gt;
              &lt;option value="3"&gt;Test 3&lt;/option&gt;
              &lt;option value="4"&gt;Test 4&lt;/option&gt;
          &lt;/select&gt;
      &lt;/td&gt;
      &lt;td&gt;&lt;input type="text" value="" class="cost" /&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
      &lt;td&gt;
          &lt;select class="drop"&gt;
              &lt;option value="1"&gt;Test 5&lt;/option&gt;
              &lt;option value="2"&gt;Test 6&lt;/option&gt;
              &lt;option value="3"&gt;Test 7&lt;/option&gt;
              &lt;option value="4"&gt;Test 8&lt;/option&gt;
          &lt;/select&gt;
      &lt;/td&gt;
      &lt;td&gt;&lt;input type="text" value="" class="cost" /&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>JS: </p>
  
  <pre><code>$('body').delegate(".drop", "change", function() {
      var end = this.value;
      var price = $('#price-'+ end).val();    
      $('.cost').val(price);
  
  });
  </code></pre>
  
  <p>Here is jsFiddler: <a href="http://jsfiddle.net/PLJ5H/3/" rel="nofollow">JSFIDDLER</a></p>
  
  <p>Edit: Found the solution!</p>
  
  <p>New JS:</p>
  
  <pre><code>$('body').delegate(".drop", "change", function() {
      var end = this.value;
      var price = $('#price-'+ end).val();    
      var new_cost = $(this).parents('tr').find('.cost');
      $(new_cost).val(price);
  
  });
  </code></pre>