Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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)
      )
    }
)
Source by www.stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #target #element #clicked
ADD COMMENT
Topic
Name
4+5 =