Delete Rows using Javascript

Delete table row using javascript needs element.deleteRow()

Frst row first column First row second column
Second Row First Column Second row Second Column

Delete Row

<table id="table2">
    <tr>
        <td>
            Frst row first column
        </td>
        <td>
            First row second column
        </td>
    </tr>
    <tr id="tr2">
        <td>
            Second Row First Column
        </td>
        <td>
            Second row Second Column
        </td>
    </tr>
</table>
    
<script type="text/javascript">
function delRow(){
 var rows = document.getElementById('table1').getElementsByTagName('tbody')[0].getElementsByTagName('tr');
    for (i = 0; i < rows.length; i++) {
        if ((rows[i]).id == "tr1") {
         document.getElementById('table1').deleteRow(i);  
        }
    }
}
</script>
    

No  Responses to "Delete Rows using Javascript"

Leave a Reply