title: How to add buttons dynamically in grid format (rows and columns) using javascript?
body: <p>I need to display the buttons dynamically in a row (with small space between buttons) based on the response from one server. If the buttons cross the screen, need to display the buttons in the next row. I thought of using table as below.</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-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  
  &lt;head&gt;
    &lt;style&gt;
      td {
        width: 200px;
        height: 200px;
      }
      
      button {
        width: 100%;
        height: 100%;
      }
    &lt;/style&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  
    &lt;p&gt;Table with cellspacing:&lt;/p&gt;
    &lt;table cellspacing="50"&gt;
      &lt;tr&gt;
        &lt;td&gt;&lt;button id='b1' onclick='clickbt("b2")'&gt;Month&lt;/button&gt;&lt;/td&gt;
        &lt;td&gt;&lt;button id='b2' onclick='clickbt("b3")'&gt;Savings&lt;/button&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;&lt;button id='b3' onclick='clickbt("b4")'&gt;January&lt;/button&gt;&lt;/td&gt;
        &lt;td&gt;&lt;button id='b4' onclick='clickbt("b1")'&gt;$100&lt;/button&gt;&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/table&gt;
  
    &lt;script&gt;
      function clickbt(id) {
        document.getElementById(id).focus();
      }
    &lt;/script&gt;
  &lt;/body&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Even though the code is creating buttons, I am hardcoding it two buttons per row and I am hardcoding columns as 2.
  But as I need to create the buttons dynamically based on the response from the server, Is there any solution using javascript instead of static rows and columns in html?</p>