+ 3
Hi guys! Am having a bit difficulty understanding nodes in dom. Can some one please help explain the code on the description.
2 Respostas
+ 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"
+ 2
Think of the html elements as nodes and the elements that go inside these elements as child nodes etc.