📌  相关文章
📜  定位除单击的元素之外的所有元素 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:11.108000             🧑  作者: Mango

代码示例1
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)
      )
    }
)