title: Javascript - Get changed value of input onclick
body: <p>I have an empty input in a td and I want to take the value the user is giving in on button click. Here is the code</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function change(){
    //alert changed value of x
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  
  &lt;head&gt;
  &lt;meta content="text/html; charset=utf-8" http-equiv="Content-Type" /&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
   &lt;table&gt;
    
    &lt;tr&gt;
     &lt;td&gt;Length:&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt; &lt;input type=number name="x" id="x"&gt;&lt;/td&gt;
    &lt;/tr&gt;
      &lt;/table&gt;
   &lt;button id="button" onclick="change()"&gt;&lt;/button&gt;&lt;br&gt;
    
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>