Reputation: 21
I know... it's a bit confusing....
So I have:
$("div nav ul li a").click(function () {
$(this).toggleClass("red");
});
and my question is, how do you slideToggle a div if class IS "red" on "div nav ul li a"??
$("div nav ul li a").click(function () {
$(this).toggleClass("red");
if (........... here?
});
My div...
<div id="popout" style="display:none"></div>
I can't figure it out... help!
Upvotes: 0
Views: 201
Reputation: 3657
You'll want to use the hasClass function ala:
if( $("div nav ul li a").hasClass('red') ){
...
}
Upvotes: 0
Reputation: 78006
$('div nav ul li a').click(function () {
var $this = $(this);
$.toggleClass('red');
if ($this.hasClass('red')) {
// do your thing
}
});
Upvotes: 3