drgullin / icheck

Highly customizable checkboxes and radio buttons (jQuery & Zepto)
http://fronteed.com/iCheck
7.39k stars 1.63k forks source link

Checked and Unchecked values are the same #365

Open iamthestreets opened 7 years ago

iamthestreets commented 7 years ago

When I check a box and look at the console logs it says the value is on When I uncheck a box and look at the console logs it also says the value is on

Both of these examples return a value of on.

$('#addEventAllDay').on('ifChecked', function(event){
    console.log($(this).val());
});

$('#addEventAllDay').on('ifUnchecked', function(event){
    console.log($(this).val());
 });

I want to get a true or false value depending on if the box is checked or unchecked.

How can I do this?

roberto910907 commented 7 years ago

Isn't clear what is the value in each case? You can get the true/false value with:

$('#addEventAllDay').on('ifChecked', function(event){
    console.log($(this).is(':checked'));
});

$('#addEventAllDay').on('ifUnchecked', function(event){
    console.log($(this).is(':checked'));
 });