Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial

Marcelo Retana
2,534 PointsGoing through the HTMl to get Node Types
Hello you all I need some help wit a HTMl and JS code I am working.
I have a basic HTMl structure with just this structure
<head>
<meta charset="UTF-8">
<title>Examen 1</title>
</head>
<body onload="myFunction();">
<div id="end"></div>
</body>
I need to go through the full HTMl and them printig out in a different <div> which is created directly from the JS document the type of node, examples: Element Node, Text Node and show the node name in case if have it and also I have to print the node childs and siblings. The most I need is the Node Types. I do not have an idea where to start. I have this JS code created already where I am creating a list that I have to go thrugh as well lately.
var btn=document.createElement("BUTTON");
var t=document.createTextNode("CLICK ME");
btn.appendChild(t);
document.body.appendChild(btn).addEventListener('click', dDiv);
function myFunction () {
var ul = document.createElement('ul'),
li = document.createElement('li');
txtNode = document.createTextNode('List 1');
ul.appendChild(li);
li.appendChild(txtNode);
document.body.appendChild(ul);
}
function dDiv () {
}
In the function dDiv () is where I have to include the node types.
Dave McFarland
Treehouse TeacherDave McFarland
Treehouse TeacherCan you show an example of the output you want? What will the output the JS prints out look like?