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

True Andrews
seal-mask
.a{fill-rule:evenodd;}techdegree
True Andrews
Front End Web Development Techdegree Student 9,045 Points

What am I missing with this code?

What do I need to add to this?

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.target){
  $('event.target').hide();
});

1 Answer

Emmanuel C
Emmanuel C
8,760 Points

Hey Andrew,

Its actually what you need to remove from your code to make a it work.

First, the call back function for the on() method takes the whole 'event' object, not just the 'event.target'

Second, the jquery in the callback function is selecting even.target as a string instead of as the variable. Simply remove the quotes an you'll be good.