Reputation: 7345
$('.comment').hide(2000);
This fades hides the class comment after two seconds. Is there an easy way to prevent a div with class "comment" from fading by adding an extra class?
<div class="comment">This text hides</div>
<div class="comment nohide">This text should not hide</div>
Adding the nohide class didn't prevent it from hiding. I'll probably end up creating a new class, but thought I'd ask.
Upvotes: 1
Views: 3750
Reputation: 647
I would use
$('.comment.fadeable').hide(2000)
if possible. As it usually looks more straightforward than "not" option. $(".x.y").hide()
applies hide()
only to divs that have "x" and "y" classes.
Upvotes: 0
Reputation: 145388
You can use :not
selector to filter elements:
$('.comment:not(.nohide)').hide(2000);
DEMO: http://jsfiddle.net/M6zgw/
Upvotes: 3