JavaScript JavaScript and the DOM Traversing the DOM Parent Traversal

Kim Dallas
Kim Dallas
11,461 Points

what am I doing wrong?

what am I doing wrong?

app.js
var removeMe = document.querySelector('.remove_me');

const removeMe = document.querySelector('.remove_me');
let parent = removeMe.parentNode;
index.html
<!DOCTYPE html>
<html>
    <head>
        <title>Parent Traversal</title>
    </head>
    <link rel="stylesheet" href="style.css" />
    <body>
        <ul>
            <li>Hello</li>
            <li>Hi</li>
            <li class="remove_me">Good bye!</li>
            <li>Howdy</li>
        </ul>
        <script src="app.js"></script>
    </body>
</html>

2 Answers

Jeremy Canela
Jeremy Canela
Full Stack JavaScript Techdegree Graduate 24,169 Points

Hey Kim, you have two variables with the same name. If you look at the console it says:

Uncaught SyntaxError: Identifier 'removeMe' has already been declared

Removing the first 'var' should solve your issue.

Kim Dallas
Kim Dallas
11,461 Points

thank you Jeremy canela