0

最後の「td」をクリックして行を削除しようとしましたが、2行目を除く各行にクラス「.del」が含まれています。コードのデモについては、このリンクを確認してください

コードを修正するのを手伝ってください

jQuery(".del").click(function () {
    jQuery(this).closest("tr:not(':first')").remove();
    //jQuery(this).closest("tr").remove();
});
4

3 に答える 3

3

あなたが試すことができます:

jQuery(".del").click(function() {
     jQuery(this).closest("tr:not(':first-child')").remove();
});

jQuery(this).closest("tr:not(':first')")-これは事実上tr、「最も近いものを選択します。これは正確に1つの要素であり、セットから要素を削除:firstします。つまり、何も残しません」。

于 2013-08-23T05:29:34.840 に答える
0
 jQuery(".del").click(function() {
  $tr = jQuery(this).closest("tr");
  if(!$tr.is(':first-child')) {
   $tr.remove();
  }
 });
于 2013-08-23T05:57:52.380 に答える
0

試す

jQuery("tr:not(:first-child) .del").click(function() {
    jQuery(this).closest("tr").remove();
    //jQuery(this).closest("tr").remove();
});
于 2013-08-23T05:31:17.603 に答える