Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get current state of check box jquery [duplicate]

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);
});
like image 909
user3316523 Avatar asked May 28 '14 12:05

user3316523


2 Answers

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

ckb = $("#ickb").is(':checked');
like image 178
Balachandran Avatar answered Nov 06 '22 12:11

Balachandran


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
like image 20
Adil Avatar answered Nov 06 '22 11:11

Adil