This article mainly introduces how jquery dynamically adds a delete row of data, the need for friends can refer to the following
<title> Add, delete one line </title>
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">
<script type= "Text/javascript" src= ". /js/jquery-1.9.1.js "></script>
<script type= "Text/javascript" >
$ (function () {
$ ("#addOneRow"). Click (function () {
var temptr = $ ("Tr:first"). Clone (True);
$ ("Tr:last"). After (TEMPTR);
$ ("Tr:last > td > #name"). Val ("");//new add row name is empty
$ ("Tr:last > td > #address"). Val ("");//new Add row address is empty
});
$ (". Delonerow"). Click (function () {
if ($ ("tr"). Length < 2) {
Alert ("Keep at least one row!");
} else {
if (Confirm ("Confirm deletion?") {
$ (this). Parent (). Parent (). remove ();
}
}
});
});
</script>
<body>
<table border= "1" >
<tr>
<td> name:</td>
<td><input type= "text" id= "name" name= "name"/>
</td>
<td> Address:</td>
<td><input type= "text" id= "Address" name= "Address"/></td>
<td><input type= "button" class= "Delonerow" value= "Delete"/></td>
</tr>
</table>
<input type= "button" id= "Addonerow" value= "Add Row"/>
</body>