title: How to add data to table on click of button using Javascript
body: <pre><code>&lt;html&gt;
  &lt;head&gt;
  
  &lt;style type="text/css"&gt;
  
  table, th, td {
      position: relative;
     border: 1px solid black;
     width: 40%;
     height:40px;
     top: 5%;
  }
  
  &lt;/style&gt;
  
  
  &lt;script type="text/javascript"&gt;
  
  function lab() 
  {
      var x= document.getElementById('lab').value;
      var rows="";
      rows+= "&lt;tr&gt;&lt;td&gt;"+x+"&lt;/td&gt;&lt;/tr&gt;";
  
  }
  
  function inp()
  {
      var y= document.getElementById('inp1').value;
  }
  
  &lt;/script&gt;
      &lt;/head&gt;
          &lt;body&gt;
                  &lt;button id="lab" onclick="lab()" value="label"&gt;Label&lt;/button&gt; 
  
                  &lt;button id="inp1" onclick="inp()" value="Input"&gt;Input&lt;/button&gt; 
  
                  &lt;button id="res" onclick="reset()"&gt;reset&lt;/button&gt;
              &lt;/body&gt;
  
              &lt;table id="me1"&gt;
                  &lt;tr&gt;
                      &lt;td&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tbody&gt;&lt;/tbody&gt;
  
              &lt;/table&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/DMkDh.png" rel="nofollow"><img src="https://i.stack.imgur.com/DMkDh.png" alt="enter image description here"></a></p>
  
  <p>I am trying to add the text in the column of the table on the click of the button.</p>
  
  <p>so please help me to add the text written on the button in the column of the table</p>
  
  <p>thank you</p>