题解 | #点击按钮隐藏元素#
点击按钮隐藏元素
https://www.nowcoder.com/practice/9b0016737b3040aaa61316890f1ac3f8
.box { width: 100px; height: 100px; border: solid 1px black; /*补全代码*/ position:relative; } .btn{ width: 20px; height: 20px; background-color: red; /*补全代码*/ position: absolute; right: -10px; top: -10px; text-align:center; line-height:20px; } var btn = document.querySelector('.btn'); var box = document.querySelector('.box'); btn.onclick = function(){ // 补全代码 box.style.display = "none"; }