Reputation: 9939
I have an if statement where I want to say IF
a check box is NOT checked and the div has a class of checkBoxID
, run the function.
The problem I have is how to use the :not
selector with this
$(this:not(:checked))
does not work. I would like to know if there is a way to use the :not
selector in the same manor as you would when running a function when a check box IS selected.
Here is my current function below.
if ($(this).is(':checked') && $('div').hasClass(checkBoxID))
{
// do something..
}
So just to clarify, this current function works when the check box is checked, I want it to work in the opposite direction when the check box is NOT clicked.
Thank you!
Upvotes: 0
Views: 489
Reputation: 82287
Sorry to re-iterate, AndreasAL answered this as well.
$(this:not(:checked))
will not work because the syntax is wrong, it should be
$(this.not(:checked))
Upvotes: 0