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?
Inside the for
loop, what name is used to refer to each individual button element?
What will event.target
refer to inside the event listener?
What event is being listened for?
What attribute on the save button would have contained the contentID
?
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.