Answers for "target all element besides the clicked one"

0

target all element besides the clicked one

let color = document.querySelectorAll('.color')
let gold = 'gold'

color.forEach(
  (c) => c.onclick = (e) => {
      color.forEach(
        (c) => c.classList[e.target==c?'toggle':'remove'](gold)
      )
    }
)
Posted by: Guest on March-26-2020

Code answers related to "target all element besides the clicked one"

Code answers related to "Javascript"

Browse Popular Code Answers by Language