Reputation: 35863
How to refactor the follow to put NOT is(":checked") syntax, instead put the codes being executed in the else block?
if ($(this).is(":checked")) {
// do nothing
}
else {
// To do here
}
Thanks for all the help.
Upvotes: 1
Views: 81
Reputation: 20246
Do you want this, or am I missing something?
if( $(this).is(":checked") == false)
{
// To do here
}
Upvotes: 1
Reputation: 630459
You would add a negation (!
) to it, like this:
if (!$(this).is(":checked")) {
But you can just use the checked
DOM property directly here, which is much faster:
if (!this.checked) {
Upvotes: 6