mardi 3 septembre 2019

How can I change checkbox value using jQuery depending on checkbox checked or not?

if checkbox checked value will be 1 if not checked value will be 0

I can be able to get is checked or not but can't change value if checked value will be 1 if not checked value will be 0

HTML

<input type="checkbox" value="0" class="custom-control-input" name="is_Current" id="isCurrentExperience">

Current

jQuery

$('#isCurrentExperience').change(function () {
        if ($('#isCurrentExperience').is(':checked') == true){
            $('#endDate').val('').prop('disabled', true);
            //console.log('checked');
        } else {
            console.log($('#isCurrentExperience').val('0'));
            $('#endDate').val('').prop('disabled', false);
            //console.log('unchecked');
        }
    });

But also need to change value after checked or not checked.




Aucun commentaire:

Enregistrer un commentaire