0
我試圖將一行從一個表移動到另一個表中,然後再返回。使用jQuery將表中的行從一個表移動到另一個表
我有這個工作去第一個表,但回去的事件沒有發射。這裏是我的代碼
HTML
<table id="table_source">
<tbody>
<tr>
<td>Row</td>
<td>1</td>
<td><img src='move_image_path' alt='Move' class='move-row' /></td>
</tr>
<tr>
<td>Another Row</td>
<td>2</td>
<td><img src='move_image_path' alt='Move' class='move-row' /></td>
</tr>
</tbody>
</table>
<table id="table_dest" class="active"><a href="#">People</a>
<tbody>
<tr>
</tr>
</tbody>
</table>
jQuery的
$("#table_source img.move-row").click(function (e) {
var tr = $(this).closest("tr").remove().clone();
tr.find("img.move-row")
.attr("src", "remove_image_path.jpg")
.attr("alt", "Remove");
$("#table_dest tbody").append(tr);
});
$("#table_dest img.move-row").click(function (e) {
alert("hi") //THIS IS NOT FIRING
var tr = $(this).closest("tr").remove().clone();
tr.find("img.move-row")
.attr("src", "move_image_path.jpg")
.attr("alt", "Move");
$("#table_source tbody").append(tr);
});