Monday, May 20, 2024
46
rated 0 times [  49] [ 3]  / answers: 1 / hits: 56969  / 12 Years ago, wed, january 9, 2013, 12:00:00

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.


More From » google-chrome

 Answers
40
(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;
}
})()

[#80974] Tuesday, January 8, 2013, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
parker

Total Points: 259
Total Questions: 109
Total Answers: 97

Location: Zambia
Member since Thu, Jun 25, 2020
4 Years ago
;