Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is Checkbox checked by name?

 
Steve Dyke
Ranch Hand
Posts: 1642
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This code seems to always act as is check box is checked even when I un check it.

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65112
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The expression $("input[name='usertextmsgcntrl']:checked") always returns a jQuery wrapped set, which is truthy, so the expression always evaluates to true.

What you want to check is the length of the set. If the checkbox is checked the wrapped set will not be empty.
 
Steve Dyke
Ranch Hand
Posts: 1642
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bear.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic