-1

How can a checkbox be checked using JavaScript: (cpf="45258236978")

<input type="checkbox" style="vertical-align: bottom;" id_pasta="26337043" cpf="45258236978" id_tarefa="122525428">
  • See this: https://stackoverflow.com/questions/8206565/check-uncheck-checkbox-with-javascript and this: https://stackoverflow.com/questions/2694640/find-an-element-in-dom-based-on-an-attribute-value – aerial Nov 30 '21 at 13:36
  • Does this answer your question? [Check/Uncheck checkbox with JavaScript](https://stackoverflow.com/questions/8206565/check-uncheck-checkbox-with-javascript) – Ruzihm Nov 30 '21 at 19:25

2 Answers2

0
 document.getElementById("yourCheckboxID").checked = true;
Theya
  • 63
  • 3
0
let check = document.querySelectorAll('input[type=checkbox]');
for (var i = 0; i < check.length; i++) {
    for (var ii = 0; ii < check[i].attributes.length; ii++) {
        if (check[i].attributes[ii].nodeValue == '45258236978') {
            check[i].checked = true;
        }
    }
}