Reputation: 233
I'm trying to hide a div, based on whether another div has a class.
I can't give the class/classless div an ID -- since everything is sitting on hidden templates that I' can't get to.
Seems like I should be able to say if this div has a class, do xx to this other div.
I'm sure I'm making a super basic syntax mistake, but all the parentheses seem like they're in the right place.
Here's what I've got:
if ( $('div').hasClass( '.test-class' ) ) {
$( ".to-hide" ).css("display", "none");
}
Embarrassed thanks, as always.
//Updated// Thanks!
Upvotes: 0
Views: 41
Reputation: 22619
Remove .
in your class
if ( $('div').hasClass( 'test-class' ) )
Upvotes: 0