我动态地在表格中创建了一行
var index = 1;
$("#add_field").click(function(){
var new_field = '<tr><th style="text-align: left;">Customer '+index+'</th><td><input type="text" id="customer'+index+'" name="customer'+index+'" maxlength="50"></td><th style="text-align: left;">Phone</th><td><input type="text" id="customerphone'+index+'" name="customerphone'+index+'" maxlength="14"></td><th style="text-align: left;">Email</th><td><input type="text" id="customeremail'+index+'" name="customeremail'+index+'" maxlength="100"></td></tr>';
$("#customerFormTable").append(new_field); });
HTML
<div id="add_field">Click here to add more rows </div>
我现在如何创建删除 - 删除我刚创建的最后一行
<div id="delete_row">Click here to delete last row created </div>
$("#delete_row").click(function(){ ??????
答案 0 :(得分:2)
$("#customerFormTable tr:last").remove();
答案 1 :(得分:0)
根据删除该特定行
给予元素TR的Id$("#trid").remove();