title: Delete Table row using javascript
body: <p>I have an HTML table with insert and delete row functionality and its working perfectly. But delete functionality works with checkbox + delete button.</p>
  
  <p>When i want to delete a row, first i checked the checkbox and then press delete button. I want to make it directly with delete button. Below is my code,</p>
  
  <pre><code>function deleteRow(tableID)
  {
  try
       {
      var table = document.getElementById(tableID);
      var rowCount = table.rows.length;
          for(var i=0; i&lt;rowCount; i++)
              {
              var row = table.rows[i];
              var chkbox = row.cells[0].childNodes[0];
              if (null != chkbox &amp;&amp; true == chkbox.checked)
                  {
                  if (rowCount &lt;= 1)
                      {
                      alert("Cannot delete all the rows.");
                      break;
                      }
                  table.deleteRow(i);
                  rowCount--;
                  i--;
                  }
              }
          } catch(e)
              {
              alert(e);
      }
     getValues();
  }
  
  &lt;a onclick="deleteRow('dataTable')"&gt;Delete Row&lt;/a&gt;
  
  &lt;table id="dataTable"&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;input type="checkbox" name="chk"/&gt;&lt;/td&gt;
      &lt;td&gt;&lt;input type="text" name="Name"&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>Note : Atleast 1 row should be there (Cannot delete all the rows)</p>