The use of JS in the table to add tbody block, convenient to add and delete the whole block, the following is added.
<table width= "border=" 1 "cellspacing=" 0 "cellpadding=" 0 "id=" table1 "></table><script language=" JavaScript ">var value =" Content ", var value1 =" <a href= ' * ' >link</a> "; var row = 5; Create 5 rows var col = 7; Create 7-grid var tbody = document.createelement ("tbody"); Create a new element node of type Tbody
var tbody1=document.createattribute ("Tbody1");
for (Var i=0;i<row;i++) {var tr = document.createelement ("tr");//Create a new element node for the TR type for (Var j=0;j<col;j++) c1/>{ var td = Document.createelement ("TD");//Create a new element node for TD type td.innerhtml = value1;//link .... Tr.appendchild (TD);//Add node TD to TR Tbody.appendchild (TR); Add the node tr to tbody}var Parnode = document.getElementById ("table1"); Locate the Parnode.appendchild (TBODY) on the table; Add node tbody to node tail </script>
Once you add a TR, you can use the following
<script>var i=0,arr=new Array (' f9f9f9 ', ' f0f0f0 '); function AddNew () {
var parnode = document.getElementById ("table1"); Navigate to Table Tr=parnode. InsertRow (); tr.style.backgroundcolor=arr[i%2];
Tr.insertcell (). innertext= "Picture" + (++i);
Tr.insertcell (). innerhtml= ' <input type=file name=pic ' +i+ ' class= "Border_index" > <a href=javascript:void (0) Onclick=del () > Delete </a> '
}}
The whole block is only required to remove
<script language= "JavaScript" >
var parnode = document.getElementById ("table1"); Navigate to Table
var tbody;
if (-[1,]) {//Non IE
Tbody=document.getelementsbytagname ("tbody") [0];
}else{//ie
Tbody=document.getelementsbytagname ("tbody") [0];
}
Deleting one TR line at a time can be done in the following ways
<script language= "JavaScript" >
var Parnode=document.getelementbyid ("Table1");
Parnode.deleterow (2);//Remove the third row TR from the table
</script>
JS adds tbody blocks to the table to facilitate the addition and deletion of whole blocks