fill in the blanks to select all div elements and alert the content of the third div. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 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..🙏

7th Nov 2020, 4:24 PM
HANUMANTHA B
HANUMANTHA B - avatar
3 Answers
+ 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/
7th Nov 2020, 4:50 PM
Ipang
+ 1
Fill in the blanks to target all div and main elements. div main background-color: gray; }
25th Mar 2023, 4:38 AM
KALAIYARASAN C
0
divs=[...document.querySelectorAll(‘div’)] third=divs[2].textContent
9th Nov 2020, 12:14 AM
Logomonic Learning
Logomonic Learning - avatar