- 1

Am I supposed to understand this?

JavaScript 54.1 first question. Why is the first blank supposed to be document and why is there a period at the end? I think this .innerHTML thing is confusing me. I guess I just can't understand how it works.

23rd Jun 2021, 8:11 PM
Anthony Morford
Anthony Morford - avatar
3 Respuestas
+ 2
Anthony Morford The getElementsByTagName() method returns a collection of all elements in the document with the specified tag name, as an HTMLCollection object. The HTMLCollection object represents a collection of nodes. The nodes can be accessed by index numbers. The index starts at 0. 1st blank is document and next blank is paragraph tag p and you have to guess what is 3rd blank. innerHTML is used to change the contents. So here we have to change content of each p tag.
23rd Jun 2021, 8:17 PM
A͢J
A͢J - avatar
+ 2
Anthony Morford Maximum people have limited knowledge but if you learn lessons carefully then you can get your answer. If you see the lesson 46.1 there is already given the answer of your question. See this example already given in lesson 46.1 which is the answer of problem 54.1 var arr = document.getElementsByTagName("p"); for (var x = 0; x < arr. length; x++) { arr[x]. innerHTML = "Hi there"; } If you can't able to solve any quiz question then you need to review the lessons again to get answer.
23rd Jun 2021, 8:34 PM
A͢J
A͢J - avatar
0
It seems like document is arbitrarily used. Couldn't it be any variable name as long as it's consistent? Maybe there should be a selection of values at the bottom like other lessons. It just doesn't make sense that someone with limited knowledge would be capable of coming up with that on their own.
23rd Jun 2021, 8:26 PM
Anthony Morford
Anthony Morford - avatar