JavaScript JavaScript and the DOM Traversing the DOM Parent Traversal

Susan Stufflebean
Susan Stufflebean
7,466 Points

I am stuck on task 2 and cannot get passed it, can someone please help?

I pass Task 1 but can't seem to get pass Task 2 any suggestions?

app.js
const removeMe = document.querySelector(".remove_me");
var 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

Lucian Rotari
Lucian Rotari
12,007 Points

Hi Susan, in task 2 you have to remove

  <li class="remove_me">Good bye!</li>

from its parent "ul".

const removeMe = document.querySelector(".remove_me");
let parent = removeMe.parentNode;

parent.removeChild(removeMe);