title: How to read input from text on button click unobtrusively in Javascript?
body: <p>How to read input from text on button click unobtrusively in Javascript? Can anyone provide a sample?</p>
  <pre><code>&lt;script type=&quot;text/javascript&gt;
  window.onload = function() {
  
  var btn = document.getElementById(
      &quot;btn&quot;
  );
  btn.addEventListener(&quot;click&quot;,function() { alert(&quot;bar&quot;); },false);
  
  }
  &lt;/script&gt;    
  </code></pre>
  <p>and in the body:</p>
  <pre><code>&lt;div id=&quot;content&quot;&gt;
  &lt;input type=&quot;text&quot; id=&quot;percent&quot; value=&quot;&quot; /&gt;
  &lt;button id=&quot;btn&quot;&gt;click&lt;/button&gt;&lt;/div&gt;
  </code></pre>