• How to Delete Rows from Table using Javascript

    Posted on February 16, 2013 by in Javascript, Other Programming

    <head runat="server">
        <link type="text/css" rel="Stylesheet" href="Styles.css" />
        <script language="javascript" type="text/javascript">
            function fnDeleteRows() {
                for (var i = document.getElementById("tblProducts").rows.length; i > 1; i--) {
                    document.getElementById("tblProducts").deleteRow(i - 1);
        <form id="form1" runat="server">
        <a href="javascript:fnDeleteRows();">Delete All</a>
        <table id="tblProducts" runat="server" class="tableClass">  
                    <th>Product ID</th><th>Product Number</th>  
                    <th>Product Name</th><th>Price</th>                  
                    <td>100</td><td>Adjustable Race</td>  
                    <td>101</td><td>Bearing Ball</td>  
                    <td>102</td><td>Headset Ball Bearings</td>  

    Delete Rows from Table using Javascript 1

    Clicking on DeleteAll link will clear all rows from table.
    Delete Rows from Table using Javascript 2

    Be Sociable, Share!
      Post Tagged with , , ,

    Written by

    View all articles by

    Email : [email protected]

    Leave a Reply