JavaScript JavaScript and the DOM Traversing the DOM Parent Traversal

kingdavid igbayilola
kingdavid igbayilola
8,678 Points

javascript DOM

i am getting confused here with traversal

const removeMe = document.querySelector('.remove_me');
let parent.addEventListener('click', (event)=> {
  if ( == 'LI') {
    let li =;
  let ul = li.parentNode;
<!DOCTYPE html>
        <title>Parent Traversal</title>
    <link rel="stylesheet" href="style.css" />
            <li class="remove_me">Good bye!</li>
        <script src="app.js"></script>

2 Answers

Steven Parker
Steven Parker
182,617 Points

Task 1 says, "On line 2 of app.js, traverse to the parent element of the removeMe element.". This will only involve making an assignment to the "parent" variable. You won't need to establish an event listener, use any conditional code, or create any other variables. And as mentioned in the instructions, only one new line of code will be added.

And when you get to task 2, it also will need only one additional line of code.

You just need to change line 2 only. “Let parent = removeMe.parentNode;”