title: jQuery .next() and .previous()
body: <pre><code>Aug: &lt;input type="text" value="100000" name="targetMonth_8" id="targetMonth_8" class="targetMonth" disabled&gt;
  Sep: &lt;input type="text" value="100000" name="targetMonth_9" id="targetMonth_9" class="targetMonth" disabled&gt;
  Oct: &lt;input type="text" value="100000" name="targetMonth_10" id="targetMonth_10" class="targetMonth active"&gt;
  Nov: &lt;input type="text" value="100000" name="targetMonth_11" id="targetMonth_11" class="targetMonth active"&gt;
  Dec: &lt;input type="text" value="100000" name="targetMonth_12" id="targetMonth_12" class="targetMonth active"&gt;
  </code></pre>
  
  <p>For the purpose of this demo, pretend the current month is October. AUG/SEP is not editable because it is prior to the current month (October). Therefore, Oct, Nov and Dec are editable. If the user edits October, I want to dynamically get the next active input, where I will be making changes so as to auto-balance the system.</p>
  
  <p>I also have an indicator on the page to set whether the NEXT or PREVIOUS month is to be targeted for auto-balancing.</p>
  
  <p>eg:
  <em>if indicator is DOWNWARDS then</em></p>
  
  <ul>
  <li>if user edits Oct, I want to know the id of Nov and its value.</li>
  <li>if user edits Nov, I want to know the id of Dec and its value.</li>
  <li>if user edits Dec, I want to know the id of Oct and its value.</li>
  </ul>
  
  <p><em>if indicator is UPWARDS then</em></p>
  
  <ul>
  <li>if user edits Oct, I want to know the id of Dec and its value.</li>
  <li>if user edits Nov, I want to know the id of Oct and its value.</li>
  <li>if user edits Dec, I want to know the id of Nov and its value.</li>
  </ul>
  
  <p>How would I use jQuery to dynamically get the name and value of the NEXT or PREVIOUS input WHERE CLASS is "active"?</p>
  
  <p>ie:</p>
  
  <pre><code>&lt;script&gt;
  $('#targetMonth_{$monthNumber}').keyup(function() {
    balanceDirection = $('#balanceDirectionValue').val();
    if (balanceDirection=='down') {
      balanceInputID = &lt;next input's ID&gt;;
      balanceInputValue = &lt;next input's value&gt;;
    }
    if (balanceDirection=='up') {
      balanceInputID = &lt;previous input's ID&gt;;
      balanceInputValue = &lt;previous input's value&gt;;
    }
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>I've tried using:</p>
  
  <blockquote>
    <p>$('#targetMonth_{$monthNumber}').nextAll('.active').val()</p>
  </blockquote>
  
  <p>Something like that, I'm not sure... Please assist. I'm open to changes if this can be done in another way.</p>