- 1
fill in the blanks to select all div elements and alert the content of the third div.
In this code the div is ok but how's the 2 will come.. Please anyone explain it to ke..đ
3 RĂ©ponses
+ 1
Method getElementsByTagName collects all matching elements into an HTMLCollection which can act like an array. We can refer to any one of its items by index.
As you may have learned, an array index starts with zero, which refers to the first item in collection. So in that quiz, index 2 refers to the third item in the HTMLCollection.
Index 0 | 1 | 2
Item. 1 | 2 | 3 đ
https://www.sololearn.com/learn/JavaScript/2753/
+ 1
Fill in the blanks to target all div and main elements.
div
main
background-color: gray;
}
0
divs=[...document.querySelectorAll(âdivâ)]
third=divs[2].textContent