排它思想

利用排他思想的案例

let building = document.querySelector("aside")
/* 排他思想 */
for(let i = 0 ;i<building.children.length;i++){
    building.children[i].onclick = function(e){
        for(let j =0;j<building.children.length;j++){
            building.children[j].classList.remove("active")
        }
        this.classList.add("active")
    }
}
posted @ 2023-09-13 14:20  饼MIN  阅读(15)  评论(0)    收藏  举报