Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check all Checkboxes in Page via Developer Tools

I have a loop that creates 20 check-boxes in the same page (it creates different forms). I want via chrome developer tools to run a JavaScript without the use of any library that CHECK all check-boxes at the same time.

This is as far as I got:

function() {     var aa= document.getElementsByTagName("input");     for (var i =0; i < aa.length; i++){      aa.elements[i].checked = checked;     } } 

PS: I have searched and found a lot of Questions in Stack-Overflow but none worked for me, I'll be glad if someone could find me the correct answer.

like image 545
Ignacio Correia Avatar asked Jan 09 '13 20:01

Ignacio Correia


People also ask

How do I view all checkboxes in Chrome?

Simply check or uncheck multiple checkboxes at a time by clicking and dragging. Allows you to check multiple checkboxes quickly by CLICKING & DRAGGING or even quicker with an ALT+CLICK & DRAG area select. You may need to refresh your browser window after installation for this extension to work.

How do you select all boxes on a website?

In order to select all the checkboxes of a page, we need to create a selectAll () function through which we can select all the checkboxes together. In this section, not only we will learn to select all checkboxes, but we will also create another function that will deselect all the checked checkboxes.


1 Answers

(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;     } })() 
like image 155
Musa Avatar answered Sep 28 '22 07:09

Musa