mercredi 4 mai 2016

How to checked all checkbox by javascript and except some checkbox ref by id?

How to checked all checkbox by javascript and except some checkbox ref by id ?

http://ift.tt/1rnNT1k

On my code. When press button. All checkbox will checked.

But i want to except not checked checkbox id 111 and id 222

How to do ?

<script>
function js_fn() {
    var all_checkbox_inputs = document.getElementsByTagName("input");
    for (var i = 0, max = all_checkbox_inputs.length; i < max; i++){
        if (all_checkbox_inputs[i].type === 'checkbox')
            all_checkbox_inputs[i].checked = true;
    }
}
</script>

Aucun commentaire:

Enregistrer un commentaire