mercredi 2 septembre 2015

Cannot modified checkbox with javascript

I have this code in html I want to change the checkbox check and uncheck event using javascript on some event so I am calling function ChangeCheckBox() on button click

<div>
    <label class="checkbox line">
        <input type="checkbox" id="Add" />Add</label>
</div>
<script>
    function ChangeCheckBox() {
        var AddCheck = 0;
        if (AddCheck == 1) {
            document.getElementById("Add").checked = true;
        } else {
            document.getElementById("Add").checked = false;
        }
    }
</script>

So in above condition check box should unchecked but its not happening checkbox is remaining checked after running this code




Aucun commentaire:

Enregistrer un commentaire