JavaScript JavaScript and the DOM Traversing the DOM Parent Traversal

Joseph Frazer
Joseph Frazer
5,404 Points

removeChild not working properly?

removeChild in this code doesn't seem to work.

app.js
const removeMe = document.querySelector('.remove_me');
let parent = removeMe.parentNode;
parent.removeChild;
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>

1 Answer

Brendan Whiting
MOD
Brendan Whiting
Front End Web Development Treehouse Moderator 84,069 Points

Line 3 you need to call the function and pass in as an argument the node that you want to remove.

parent.removeChild(removeMe);