39

I am using Bootstrap iCheck plugin. How can i find out Whether a check box is checked or not by pressing a button using jquery

$(button).click(function(){

  ckb = $("#ickb").(isChecked);
});
1
  • 1
    Starting jquery 1.6 there have been significant changes the way attributes and properties are dealt with. For your case $('#ickb').prop("checked") should do the trick. This statement will simply return true or false depending upon the checked/unchecked state of the check box. For more details refer to attributes vs. properties section on this link.
    – RBT
    Commented Feb 12, 2016 at 18:36

2 Answers 2

73

Try to use .is() function along with :checked selector to accomplish your task,

ckb = $("#ickb").is(':checked');
20

Use is() with :checked to get the result as boolean that is true if checkbox is checked.

ckb = $("#ickb").is(':checked');

Or, you can use length, if it is zero then it is not checked.

ckb = $("#ickb:checked").length
1
  • The second option is a single column like so $("#ickb:checked").length Your answer helped me Commented Oct 9, 2017 at 23:47

Not the answer you're looking for? Browse other questions tagged or ask your own question.