Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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
34,236 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");

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.