title: How to get an input text value in JavaScript
body: <p>How go get an input text value in JavaScript?</p>
  
  <pre><code>&lt;script language="javascript" type="text/javascript"&gt;
      lol = document.getElementById('lolz').value;
      function kk(){
      alert(lol);
      }
  &lt;/script&gt;
  
  &lt;body&gt;
      &lt;input type="text" name="enter" class="enter" value="" id="lolz"/&gt;
      &lt;input type="button" value="click" OnClick="kk()"/&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>When I put <code>lol = document.getElementById('lolz').value;</code> outside of the function <code>kk()</code>, like shown above, it doesn't work, but when I put it inside, it works. Can anyone tell me why?</p>