开发者

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
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜