jeudi 17 mars 2016

Add boolean in checkbox value

Hi how to add if checkbox is check in input value true and when checkbox is uncheck false?

I try like this but it dosen't work:

$('#analytics').change(function(){
    if($("#analytics").prop('checked')){
        $("#analytics").val('true');
        console.log(analytics);
    }else{
        $("#analytics").val('false');
        console.log(analytics);
    }
});

JSFIDDLE




Aucun commentaire:

Enregistrer un commentaire