簡體   English   中英

首先顯示全部 <tr> 元素,然后隱藏除一個類之外的所有元素

[英]First show all <tr> elements, then hide all except one class

我有用於過濾表內容的不同類。 如何編輯此代碼,因此在單擊按鈕(#aipa)之后,首先查看所有<tr>元素,然后僅顯示(過濾)具有類的行。 現在,當我篩選AIPA元素時,則無法篩選表格中的任何其他元素。

$("#aipa").click(function(){
        $('tr:not(:first)').not(".AIPA").slideToggle('fast');
});

嘗試這個,

$(document).ready(function(){
   $("#aipa").click(function(){
      $('tr').hide(); // hiding all trs
      $("tr.AIPA").fadeIn('fast'); // showing the tr havin AIPA class
   });
});

現場演示

如果要隱藏除first row和具有.AIPA class的行以外的所有行,請嘗試以下方法,

$(document).ready(function(){
   $("#aipa").click(function(){
       $("tr:not(:first, .AIPA)").fadeOut(1000);
   });
});

更新的演示

您也可以像這樣組合它們:

$('tr:not(":first, .AIPA")').slideToggle('fast');

也許這可能會幫助您:

$('tr:not(:first)').add(':not(".AIPA")').slideToggle('fast');

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM