[英]How to Add/remove row in table in jquery when we check and uncheck the checkbox in other table?
我有一張桌子,我通過選中復選框來選擇該行。 我想將選定的復選框行添加到另一個表中,該表是在某個復選框被選中時動態創建的。
我在等你的回復
就像是
$("#firsttableid input:checkbox").click(function(){
$(this).closest("tr").appendTo("#yoursecondtableid");
});
編輯
如果您不想移動該行,則可以使用.clone()到該行,然后追加到另一個表中。 另外,單擊處理程序中的一項更改是在取消選中復選框時不添加行。 如果您不想一次又一次地添加一行,則也必須注意這一點。
$("#firsttableid input:checkbox").click(function(){
if ($ (this).is(":checked"))
{
$(this).closest("tr").clone().appendTo("#yoursecondtableid");
}
});
基本上如rahul所建議的那樣,但添加了clone()進行了少量添加
$('#first_table_id input:checkbox').click(function() {
$(this).closest('tr').clone().appendTo('#second_table_id');
});
jQuery API文檔是您的朋友:)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.