title: Initialize onchange event inside a loop - Javascript
body: <p>I'm trying to bind an onChange event to 7 dropdowns inside a loop. But when any of dropdown changes, the onChange event for the last one is always executed.</p>
  
  <pre><code>$(function () {
      for (var i = 1; i &lt;= 7; i++) {
          $('select[id$="bodysys' + i + '"]').change(function () {
              if (this.value == "99")
                  enabletextbox($('input[id$="bodysys' + i + 'spec"]')[0]);
          });
      }
  }
  </code></pre>
  
  <p>How to make onChange work for all elements separately?</p>