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! While you're at it, check out some resources Treehouse students have shared here.

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

JavaScript Interactive Web Pages with JavaScript Traversing and Manipulating the DOM with JavaScript Traversing Elements

Need a little help

On line 14 of the app.js, we want to get the anchor (the a element) from inside the listItem. Use a method to traverse and select the anchor.

Bardhyl Bytyqi
Bardhyl Bytyqi
14,558 Points

what I have to do I this example. please help me.

2 Answers

Patrick Koch
Patrick Koch
40,496 Points

Hello Quintin, The querySelector() will help ;-)

Exp. for your app.js if you write

var incompleteTasksHolder = document.getElementById("incomplete-tasks"); //incomplete-tasks

var selecta = incompleteTasksHolder.querySelector("label");
console.log(selecta);

the console shows you the select element, if you have more elements that fit to the enterd selectors, its just shows you the first, its pretty cool you can enter "a" for anchor or a class name like " .editMode". I personally really like the querySelector.

!!!! spoiling:

var anchor = listItem.querySelector("a");

Greetings Patrick

will do thanks.