6 odpowiedzi
+ 6
https://code.sololearn.com/W5QM0ec2J7nC/?ref=app It will not work because pa element don't exist at the time of execution of js you need to let load html first then try to change value
7th Jan 2021, 4:46 AM
Atul
Atul - avatar
+ 5
document.getElementsByTagName("p"); will return all elements as an array. Therefore you need to access the elements of the array before you can change them. Right now you are treating the return as a single element, not an array. Review lesson 46.1 of the JS tutorial.
7th Jan 2021, 4:44 AM
Elizabeth Kelly
Elizabeth Kelly - avatar
+ 1
because the Javascript is executed before the document is fully loaded
7th Jan 2021, 4:45 AM
CutieRei
CutieRei - avatar
+ 1
Do you see thd tabs in the code playground, "HTML", "CSS", "JS", "OUTPUT"? The JS tab has the error in line 2: a.innerHTML = "blue";
7th Jan 2021, 4:49 AM
HungryTradie
HungryTradie - avatar
+ 1
Name replace your javascript with this: var a = document.getElementById("pa"); a.style.color = "blue";
7th Jan 2021, 5:13 PM
Brain & Bones
Brain & Bones - avatar
0
No problem it run without error
7th Jan 2021, 4:42 PM
Masum Yosufzai
Masum Yosufzai - avatar