0

テーブルの横に動的に行を作成しました

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(){  ??????
4

2 に答える 2

2
$("#customerFormTable tr:last").remove();
于 2012-04-06T12:02:11.680 に答える
0

その特定の行を削除することに基づいて、要素 TR に Id を付与します

$("#trid").remove();
于 2012-04-06T12:06:25.393 に答える