2012-05-06 75 views
1
$('.comment').hide(2000); 

此淡入淡出類別註釋後兩秒。是否有一種簡單的方法來防止類「評論」通過添加一個額外的類淡入淡出?Jquery類選擇器和隱藏()

<div class="comment">This text hides</div> 
<div class="comment nohide">This text should not hide</div> 

添加nohide類並不妨礙它隱藏。我可能最終會創建一個新班級,但我想我會問。

+0

之前已經詢問過:http://stackoverflow.com/questions/10466940/how-to-filter-undesired-elements-with-jquery/10466957#10466957 –

回答

0

如果可能的話,我會用

$('.comment.fadeable').hide(2000) 

。因爲它通常看起來比「不」選項更直接。 $(".x.y").hide()僅適用於hide()以具有「x」和「y」類的div。