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

Fernando Jimenez
PLUS
Fernando Jimenez
Courses Plus Student 8,203 Points

Not sure what i am doing wrong here. Is event.target == ‘.student-list’? I get a little confused with event.target still

Not sure what i am doing wrong here. Is event.target == ‘.student-list’? I get a little confused with event.target still

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
$('.student-list').on('click', function(event){
  hide(event.target);  });

4 Answers

Your click event is technically triggered whenever you click on the ul, but I think it will also trigger if you click on its children

Adam Beer
Adam Beer
11,314 Points

You are near. Inside of your click handler, use jQuery ($ <- jQuery selector) to 'select' event.target, then call the hide() method on your selection. Hope this help.

Mike Hatch
Mike Hatch
14,940 Points

You have it pretty close, but some things are out of order. First line is correct, so now we move to the second line.

hide() is the method the Challenge is asking you to "call". When attaching a method, there will also be a dot operator. Since methods are functions that means you also need to call it. How do we call a function--we add parentheses. Like this: hide()

The other error you made was omitting the jQuery selector before (event.target). For a deeper understanding of event.target I would recommend the MDN docs.

Thomas Tilton-Heylin
Thomas Tilton-Heylin
12,098 Points
$('.student-list:hidden').on('click', function(){
  this.show();  
});