JavaScript jQuery Basics Understanding jQuery Events and DOM Traversal DOM Traversal with jQuery

traversal challenge

Challenge Task 2 of 2 You've just learned about the next() and prev() methods. Use one of them to traverse from Wade Christensen to James McAvoy in the list of students.

Bummer: Did you make a call to the "prev" method after calling the "eq" method on the jQuery with a selector of "li"?
index.html app.js $('li').eq(2); $('li').eq(2).prev().prev();

how is this not working am now confused. may someone help me out plis.

index.html
<!DOCTYPE html>
<html lang="en">
<head>
    <title>Document</title>
</head>
<body>
  <h2>Student List</h2>

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

  <script src="jquery-3.2.1.min.js"></script>
  <script src="app.js"></script>
</body>
</html>
app.js
$('li').eq(2);
$('li').eq(2).prev().prev();

1 Answer

Steven Parker
Steven Parker
174,022 Points

You've got the right thing, but this is one of the rare challenges that is asking you to change the task 1 code instead of adding another line.