0

Can anyone explain these code?

<html> <body> <div id ="demo"> <p>some text</p> <p>some other text</p> </div> <script> var a = document.getElementById("demo"); var arr = a.childNodes; for( var i = 0; i < arr.length; i++){ arr[i].innerHTML = "New text"; } </script> </body> </html> Here why used arr? Is these an array?

21st Dec 2016, 12:21 PM
S M Sarwar
S M Sarwar - avatar
1 ответ
0
In this instance "arr" is created as an array to hold all the child elements of the "demo" div.
21st Dec 2016, 1:08 PM
Geoff Harrison
Geoff Harrison - avatar