Check all Checkboxes in Page via Developer Tools

后端 未结 8 1325
野性不改
野性不改 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 05:40

    Try this :)

    (function () {
        var checkboxes = document.querySelectorAll('input[type=checkbox]');
    
        //convert nodelist to array
        checkboxes = Array.prototype.slice.call(checkboxes);
        checkboxes.forEach(function (checkbox) {
            console.log(checkbox);
            checkbox.setAttribute('checked', true);
        });
    
    })()
    

    http://jsfiddle.net/YxUHw/

提交回复
热议问题