Home > Web Front-end > JS Tutorial > Dynamically add and delete table rows js implementation code_javascript skills

Dynamically add and delete table rows js implementation code_javascript skills

WBOY
Release: 2016-05-16 16:57:48
Original
1171 people have browsed it
Copy code The code is as follows:



< ;script language="javascript">
//Add a row to the window table
function addNewRow(){
var tabObj=document.getElementById("myTab");//Get the table to add data
var rowsNum = tabObj.rows.length; //Get the current number of rows
var colsNum=tabObj.rows[rowsNum-1].cells.length;//Get the number of columns of the row
var myNewRow = tabObj. insertRow(rowsNum);//Insert new row
var newTdObj1=myNewRow.insertCell(0);
newTdObj1.innerHTML="";
var newTdObj2=myNewRow.insertCell(1);
newTdObj2.innerHTML="";
var newTdObj3=myNewRow.insertCell(2);
newTdObj3.innerHTML="";
var newTdObj4=myNewRow.insertCell(3);
newTdObj4.innerHTML=" ";
}
//Delete a row in the window table
function removeRow(){
var chkObj=document.getElementsByName("chkArr");
var tabObj=document.getElementById("myTab");
for(var k=0;k if(chkObj[k].checked){
tabObj.deleteRow(k 1);
k=-1;
}
}
}








                                                                                                                                       class="top-bt liebiao-c" align="center" >Node name
   
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
OperationNode proportion