Advertisement
chloecodes

AddEventListener JS

Oct 15th, 2019
442
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var myListItems = document.querySelectorAll(‘li’)
  2.  
  3. myListItems.forEach(item => {
  4.     item.addEventListener(‘click’, function () {
  5.         this.classList.add('yellowBackground')  
  6. })
  7. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement