答案

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const box = document.getElementById('box)

function isIcon(target){
return target.className.includes('icon')
}

box.onclick = function(e){
e.stopPropagation()
const target = e.target
if(isIcon(target)) {
target.style.border = '1px solide red'
}
}

const doc = document;

doc.onclick = function(e){
const children = box.children
for(let i = 0; i< children.length; i++) {
if(isIcon(children[i])) {
children[i].style.border = 'none'
}
}
}

总结:大功告成✌️✌️✌️✌️✌️✌️✌️✌️✌️✌️✌️✌️✌️✌️✌️✌️✌️✌️✌️✌️