jeudi 27 août 2020

How to change the text of an Label tag when a checkbox is unchecked

I can’t change the text of my label when I uncheck my checkbox.

Thanks in advance for your help.

    var checkBox_fruit = document.getElementById("fruit");
    var label_fruit = document.getElementById("label_fruits");

    checkBox_fruit.addEventListener('change', function () {
        if (this.checked) {
            // Checkbox is checked..

           label_fruit.innerHTML = " fruits 1"; ////// its that who works

        } else {
            // Checkbox is not checked..

           label_fruit.innerHTML = " fruits 2"; ////// its that who not works

        }



Aucun commentaire:

Enregistrer un commentaire