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)
)
}
)
Also in JavaScript:
- swift append to array
- ./src/index.js Line 0: Parsing error: Cannot find module '@babel/helper-validator-identifier'
- basic javascript
- how to use fetch() to fetch an image from database in js
- angular 7 folder structure best practices
- javascript floor
- text background fabricjs
- badlion client
- vue.js use scss in balise style
- react image upload component
- access json python
- js redirect code
- sleeping in js
- jquery click event
- json server
- sendfile express syntax
- loop through checkboxes jquery
- how to get width of inline elements js
- kendo grid add line javascript
- how run dockerfile
- remove letter js
- getting the value of pi in javascript
- javascript date double digit month
- datatable dropdown toggle not working