Why is my variable not being assigned properly? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
0

Why is my variable not being assigned properly?

https://code.sololearn.com/W29aCW6xh9yL I want to simply select the elements by class name, in this case, demo. I prefaced the variable with "var", used the document.getElementsByClassName() method, which should be an array. Yet, when I check the length of the array (in this case by using an alert), the length is zero, which means that my variable assignment didn't actually grab any of the elements. What am I missing here?

14th Feb 2020, 3:29 PM
Thomas Dowell
Thomas Dowell - avatar
1 ответ
0
Thank you so much! I new it must be something so simple, but it was driving me crazy!!
14th Feb 2020, 3:44 PM
Thomas Dowell
Thomas Dowell - avatar