how to use is()
How to refactor the follow to put NOT is(":checked") syntax, instead put the codes being executed in the else block?
i开发者_运维技巧f ($(this).is(":checked")) {
// do nothing
}
else {
// To do here
}
Thanks for all the help.
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) {
Do you want this, or am I missing something?
if( $(this).is(":checked") == false)
{
// To do here
}
精彩评论