Extra Practice

Remember: Learning to program takes practice! It helps to see concepts over and over, and it's always good to try things more than once. We learn much more the second time we do something. Use the exercises and additional self-checks below to practice.

1. Save Buttons

Review the code, then answer the questions below.

let saveButtons = document.querySelectorAll('.save-button');

for (let button of saveButtons){
    button.addEventListener('click', function(event){
        let contentID = event.target.dataset.id;
        console.log(`Saving ${contentID}`);
    });
}

What is saveButtons equal-to?

Check my answersExplainShow all

Inside the for loop, what name is used to refer to each individual button element?

Check my answersExplainShow all

What will event.target refer to inside the event listener?

Check my answersExplainShow all

What event is being listened for?

Check my answersExplainShow all

What attribute on the save button would have contained the contentID?

Check my answersExplainShow all

Visit Content Online

The content on this page has been removed from your PDF or ebook format. You may view the content by visiting this book online.

results matching ""

    No results matching ""