title: How to empty table in javascript?
body: <p>I cant delete the row contents of a table, but what if I want to delete the rows too? </p>
  
  <p>My Javascript code: (I want all the rows to disappear except the first one.)</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-js lang-js prettyprint-override"><code>function deleteAll() {
          for ( var i = 0; i &lt;= table.rows.length; i++){
              table.rows[i].cells[0].innerHTML = "";
              table.rows[i].cells[1].innerHTML = "";
              table.rows[i].cells[2].innerHTML = "";            
          }     
          
      }</code></pre>
  </div>
  </div>
  </p>
  
  <p>My HTML table:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;body&gt;
      &lt;div class="container"&gt;
          &lt;div class="tab tab-1"&gt;
              &lt;table id="table" border="1"&gt;
                  &lt;th&gt;
                      &lt;th&gt;First Name&lt;/th&gt;
                      &lt;th&gt;Last Name&lt;/th&gt;
                      &lt;th&gt;Age&lt;/th&gt;
                  &lt;/th&gt;
                  &lt;tr&gt;
                      &lt;td&gt;Frank&lt;/td&gt;
                      &lt;td&gt;Nenjim&lt;/td&gt;
                      &lt;td&gt;19&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td&gt;Alex&lt;/td&gt;
                      &lt;td&gt;Ferreira&lt;/td&gt;
                      &lt;td&gt;23&lt;/td&gt;
                  &lt;/tr&gt;
  
  
              &lt;/table&gt;      
  
          &lt;/div&gt;
          &lt;div class="tab tab-2"&gt;
              First Name :&lt;input type="text" name="fname" id="fname"&gt;
              Last Name :&lt;input type="text" name="lname" id="lname"&gt;
              Age :&lt;input type="number" name="age" id="age"&gt;
  
              &lt;button onclick="deleteAll()"&gt;Delete All&lt;/button&gt;
  
          &lt;/div&gt;
  
      &lt;/div&gt;
      &lt;script src="tableEdit.js"&gt;&lt;/script&gt;
  &lt;/body&gt;    
  </code></pre>
  
  
  
  <p>So, the Javascript code above doesn't satisfy me because I want only the first row to remain. I don't want empty rows.</p>