0

How do i select all in one shot?

i have this code here https://code.sololearn.com/Ww6A4zARPFzh/?ref=app is there a way to select all in one or two lines of code? Without rewriting the code and change just the number of the array?

22nd Aug 2017, 5:39 PM
Olm
Olm - avatar
6 Antworten
+ 6
try selecting the div tags
22nd Aug 2017, 5:42 PM
Manual
Manual - avatar
+ 4
Use a for loop to itterate over the array of elements.
22nd Aug 2017, 5:44 PM
Rrestoring faith
Rrestoring faith - avatar
+ 3
Thanks @Kamil
22nd Aug 2017, 5:55 PM
Manual
Manual - avatar
+ 1
use this code inside the your "on" function var z = document.getElementsByClassName("one"); for (var i = 0; i < z.length; i++) { z[i].style.color="blue"; }
22nd Aug 2017, 5:57 PM
Patricio Salazar
Patricio Salazar - avatar
+ 1
Thank you all for your answers.I found them all usefull!
22nd Aug 2017, 6:17 PM
Olm
Olm - avatar