40

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. Commented Feb 12, 2016 at 18:36

2 Answers 2

74

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

ckb = $("#ickb").is(':checked'); 
Sign up to request clarification or add additional context in comments.

Comments

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 Comment

The second option is a single column like so $("#ickb:checked").length Your answer helped me

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.