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 jQuery Basics Understanding jQuery Events and DOM Traversal DOM Traversal with jQuery

What's wrong with my code, it performs as intended?

I swear this test environment is full of bugs...It only want's code done only one way otherwise it will consider your code incorrect. Not very useful then since code can be written in many different ways and still produce valid outcome.

In this test, I am to select all of the ul element for '.student.list' and then using traversal, select only the li instance containing "Wade Christensen". My code does that and to prove it, I had my code change only the li element containing "Wade Christensen" and set its font color to green. This works, so what is the test's problem? How am I to learn if it always considers everything I do as being wrong despite whether it is actually wrong?

<!DOCTYPE html>
<html lang="en">
  <h2>Student List</h2>

  <ul class="student-list">
    <li>James McAvoy</li>
    <li>Alena Holligan</li>
    <li>Wade Christensen</li>
    <li>Matt Krzyzynski</li>

  <script src="jquery-3.2.1.min.js"></script>
  <script src="app.js"></script>
$(".student-list li").eq(2).css({color: 'green'});
Antonio De Rose
Antonio De Rose
20,882 Points

could you please post your answer, to the challenge 1 and 2

1 Answer

f lsze
f lsze
8,021 Points

I hear you. You're not really doing anything wrong. It's just that when they say:

select all of the list items on the page.

They literally want you to select all the list items on the page. So the correct answer would involve selecting $("li") and then doing the traversal. The difference is your code limits it to list elements within ul.student-list which is super subtle and I could definitely see why you would get frustrated. It would only actually make a difference if there were other unordered lists on the page.