I need to access the DOM tree and get the elements just 1 level below the current element.
Read the following code:
-
I've added some text so we can see that it is working, and JavaScript that will add "added!" to the bottom of each of the divs at the base:
var cDiv = document.querySelectorAll('body > div > div'), i;
for (i = 0; i < cDiv.length; i++)
{
cDiv[i].appendChild(document.createTextNode('added!'));
}
a
aa
ab
aba
b
ba
bb
bba
c
ca
cb
cba