【问题标题】:Checkbox be checked, unique custom attribute复选框被选中,唯一的自定义属性
【发布时间】:2022-01-07 05:10:29
【问题描述】:

如何使用 JavaScript 检查复选框:(cpf="45258236978")

<input type="checkbox" style="vertical-align: bottom;" id_pasta="26337043" cpf="45258236978" id_tarefa="122525428">

【问题讨论】:

标签: javascript checkbox


【解决方案1】:
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;
        }
    }
}

【讨论】:

    【解决方案2】:
     document.getElementById("yourCheckboxID").checked = true;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-04-06
      • 2014-07-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-16
      • 1970-01-01
      相关资源
      最近更新 更多