jeudi 8 février 2018

javscript: check all checkboxes in a div

i have a <div id="myDiv"> containing a few <input type="checkbox"> and <br/>. Now i want to loop through all elements of the div and do something if the element is a checkbox and checked. i have already tried

var e = document.getElementById("myDiv");
var c;
for(c in e.children){
    if(c.checked) {
        //...
    }
}

but c.checked is always undefined. Can anyone tell me how i do that?




Aucun commentaire:

Enregistrer un commentaire