title: Javascript Setting attribute onchange event to select and displaying to console stops after first selection
body: <p>I am trying to log the value of the option selected by adding an <code>onchange</code> event. The problem is it only logs once and stops. What am I missing here?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var selection = document.getElementById("test-dropdown");
  selection.setAttribute("onchange", function() {
    console.log((selection.options[selection.selectedIndex].text));
  }());</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;select id="test-dropdown"&gt;
    &lt;option value="1"&gt;One&lt;/option&gt;
    &lt;option value="2"&gt;Two&lt;/option&gt;
    &lt;option value="3"&gt;Three&lt;/option&gt;
  &lt;/select&gt;</code></pre>
  </div>
  </div>
  </p>