The code copy is as follows:
<html>
<head>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script>
//Create an html element
function $c(tagname){
return document.createElement(tagname);
}
//What to execute after the document is loaded
$(document).ready(function(){
//Bind the click event of adding row button
$("#addrow").bind("click",function(){
// Get the table
var tab = $("#tab");
// Create tr element
var tr = $c("tr");
// Append tr element to table
tab.append(tr);
// Create td element
var td1=$c("td");
// Contents of td element
td1.innerHTML="insert1";
// Append td element to the newly added tr
tr.appendChild(td1);
var td2=$c("td");
td2.innerHTML="insert2";
tr.appendChild(td2);
});
// Bind the click event of the delete row button
$("#deletero").bind("click",function(){
// Get the first line of the table
var tab = $("#tab tr:eq(0)");
// Delete this line
tab.remove();
});
});
</script>
</head>
<body>
<table border='1' id="tab">
<tr>
<td>123</td>
<td>456</td>
</tr>
</table>
</br>
<button id="addrow">Add row</button>
<button id="deletero">Delete row</button>
</body>
</html>