+ 3

Hi guys! Am having a bit difficulty understanding nodes in dom. Can some one please help explain the code on the description.

https://code.sololearn.com/WvJaVgnQZ6PB/?ref=app

21st Sep 2019, 11:20 PM
chinaza
chinaza - avatar
2 Antworten
+ 2
Ok, In the HTML file you create a <div> with 2 <p>s inside it. In your javascript file you first assign the variable 'a' to the div(it had the id of "demo" in the next line of code you assign the variable 'arr' to a list of 'a's child nodes, which in this case is the 2 <p>s. then you loop through each of values in arr and change the inner html the value of "new text"
22nd Sep 2019, 12:07 AM
Bill
Bill - avatar
+ 2
Think of the html elements as nodes and the elements that go inside these elements as child nodes etc.
22nd Sep 2019, 12:34 AM
Sonic
Sonic - avatar