Check all Checkboxes in Page via Developer Tools

后端 未结 8 1328
野性不改
野性不改 2021-01-30 05:13

I have a loop that creates 20 check-boxes in the same page (it creates different forms). I want via chrome developer tools to

8条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-30 06:02

    (function() {
        var aa= document.getElementsByTagName("input");
        for (var i =0; i < aa.length; i++){
            if (aa[i].type == 'checkbox')
                aa[i].checked = true;
        }
    })()
    

    With up to date browsers can use document.querySelectorAll

    (function() {
        var aa = document.querySelectorAll("input[type=checkbox]");
        for (var i = 0; i < aa.length; i++){
            aa[i].checked = true;
        }
    })()
    

提交回复
热议问题