Function implementation: Click the Add button, the table adds a row and gives its name attribute value, easy to get
Click Delete to automatically delete this line
A count variable is defined in jquery
1 varCount = 1;2 functionAdd () {3 varTBL =Document.all.ci;4 varrows =tbl.rows.length;5 varTR =tbl.insertrow (rows);6 7 vare_id = Tr.insertcell (0);8e_id.innerhtml = ' <input type= ' text "name=" e_id ' + Count + ' "size=" 7 "/>";9 Ten varclass_id = Tr.insertcell (1); Oneclass_id.innerhtml = ' '; A - varMemo = Tr.insertcell (2); -memo.innerhtml = ' <input type= ' text ' name= ' memo ' + Count + ' size= '/> '; the - vardel = Tr.insertcell (3); -del.innerhtml = ' <input type= ' button ' onclick= ' del (This) ' value= ' delete '/> '; -count++; + } - + functiondel (BTN) { A varTR =btn.parentElement.parentElement; at varTBL =tr.parentelement; - if(Tr.rowindex >= 1) { - Tbl.deleterow (tr.rowindex); -}Else { - - } in};
jquery Implements dynamic tables