title: Find an element in the nearest cell (td) using jquery?
body: <p>Below is a function to convert value <strong><code>A</code></strong> when value <strong><code>B</code></strong> is entered and vice versa.</p>
  
  <p>I am trying to work out an efficient way to target <strong>only</strong> the nearest matching input using <strong>javascript</strong> or <strong>jQuery</strong>.</p>
  
  <p>I've tried jQuery <a href="https://api.jquery.com/siblings/" rel="nofollow">siblings</a>, <a href="https://api.jquery.com/closest/" rel="nofollow">closest</a>, <a href="https://api.jquery.com/next-adjacent-selector/" rel="nofollow">prev</a> and <a href="https://api.jquery.com/find/" rel="nofollow">find</a>.</p>
  
  <h2>QUESTION</h2>
  
  <p>Using Javascript what is an efficient way to target an element in an adjacent cell without the search function becoming convoluted?</p>
  
  <hr>
  
  <p><a href="https://jsfiddle.net/0sL8vzL5/1/" rel="nofollow"><h2>DEMO</h2></a></p>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;td&gt;&lt;input class="A" value="0" OnChange="convertA(this.id, this.value);"/&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input class="B" value="0" OnChange="convertB(this.id, this.value);"/&gt;&lt;/td&gt;
  </code></pre>
  
  <p><strong>JQUERY</strong></p>
  
  <pre><code>function convertA(id, value) {
      $('.B').val(value * 2);
  }
  function convertB(id, value) {
      $('.A').val(value / 2);
  }
  </code></pre>