add Attributes JavaScript | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

add Attributes JavaScript

How can i add to all elements with the className "digit" the attribute r="2.5px"? -> https://code.sololearn.com/W27JVf29KuFV/#html <-

21st Aug 2018, 9:53 PM
Michelle Becker
Michelle Becker - avatar
3 Answers
+ 1
sorry i made a mistake that's why i remove first answer check this: https://code.sololearn.com/WjlRGHz2GYce/#html
21st Aug 2018, 11:20 PM
MO ELomari
+ 1
That worked: window.onload = function (){ var digits= document.getElementsByClassName("digit"); for (i = 0; i<digits.length; i++) digits[i].style.r = "2.5px"; }
21st Aug 2018, 11:20 PM
Kapi
+ 1
Thank you both 😀 you helped really much
22nd Aug 2018, 12:08 AM
Michelle Becker
Michelle Becker - avatar