0
Where did I go wrong?
6 ответов
+ 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
+ 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.
+ 1
because the Javascript is executed before the document is fully loaded
+ 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";
+ 1
Name
replace your javascript with this:
var a = document.getElementById("pa");
a.style.color = "blue";
0
No problem it run without error