最後の「td」をクリックして行を削除しようとしましたが、2行目を除く各行にクラス「.del」が含まれています。コードのデモについては、このリンクを確認してください
コードを修正するのを手伝ってください
jQuery(".del").click(function () {
jQuery(this).closest("tr:not(':first')").remove();
//jQuery(this).closest("tr").remove();
});
最後の「td」をクリックして行を削除しようとしましたが、2行目を除く各行にクラス「.del」が含まれています。コードのデモについては、このリンクを確認してください
コードを修正するのを手伝ってください
jQuery(".del").click(function () {
jQuery(this).closest("tr:not(':first')").remove();
//jQuery(this).closest("tr").remove();
});
あなたが試すことができます:
jQuery(".del").click(function() {
jQuery(this).closest("tr:not(':first-child')").remove();
});
jQuery(this).closest("tr:not(':first')")
-これは事実上tr
、「最も近いものを選択します。これは正確に1つの要素であり、セットから要素を削除:first
します。つまり、何も残しません」。
jQuery(".del").click(function() {
$tr = jQuery(this).closest("tr");
if(!$tr.is(':first-child')) {
$tr.remove();
}
});
試す
jQuery("tr:not(:first-child) .del").click(function() {
jQuery(this).closest("tr").remove();
//jQuery(this).closest("tr").remove();
});