JavaScript JavaScript and the DOM Traversing the DOM Sibling Traversal

Anton Kilk
Anton Kilk
Full Stack JavaScript Techdegree Student 7,408 Points

What means " add a class of highlight"? Does it mean just to add "style.backgroundColor" to variable?

Code Challenge in Sibling Traversal. What means "add a class of highlight"?

var list = document.getElementsByTagName('ul')[0];

list.addEventListener('click', function(e) {
  if ( == 'BUTTON') {
    let li =;
    let p = e.previousElementSibling; = 'yellow';
<!DOCTYPE html>
        <title>JavaScript and the DOM</title>
    <link rel="stylesheet" href="style.css" />
            <h1>Making a Webpage Interactive</h1>
            <p>Things to Learn</p>
                <li><p>Element Selection</p><button>Highlight</button></li>
                <li><p>Event Listening</p><button>Highlight</button></li>
                <li><p>DOM Traversal</p><button>Highlight</button></li>
        <script src="app.js"></script>

1 Answer