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

Chase Nobles
seal-mask
.a{fill-rule:evenodd;}techdegree
Chase Nobles
Full Stack JavaScript Techdegree Student 13,633 Points

Not sure why this isn't working. The question is pretty confusing..

Wondering how to get this to work. The question is pretty confusing.

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', 'ul', function(event) {

});

2 Answers

Steven Parker
Steven Parker
231,236 Points

Though this might be a good situation to use it, the instructions did not ask for descendant filtering, so you won't need that 2nd argument ('ul').

And what about 2nd option?

Steven Parker
Steven Parker
231,236 Points

That's the same as Chase's code with the 2nd argument removed, except you also added the tag name to the class selector. That works, and is perhaps more literally correct for the instructions, but it's not needed to pass the challenge.

Hi,

We need to modify code.

$('document').on('click', 'ul.student-list', function(event) { console.log("Option 1") });

or

$('ul.student-list').on('click', function(event) { console.log("Option 2") });

Both option will work

Steven Parker
Steven Parker
231,236 Points

FYI: The first suggestion shown here does not follow the instructions, and will not pass the challenge.