题解 | 点击按钮隐藏元素
点击按钮隐藏元素
https://www.nowcoder.com/practice/9b0016737b3040aaa61316890f1ac3f8
{"html":" <!DOCTYPE html>\n<html>\n <head>\n <meta charset=utf-8>\n <style type=\"text/css\">\n .box {\n width: 100px;\n height: 100px;\n border: solid 1px black;\n position: relative;\n }\n .btn{\n width: 20px;\n height: 20px;\n background-color: red;\n position: absolute;\n top: -10px;\n right: -10px;\n \n line-height: 20px;\n text-align: center;\n \n }\n </style>\n </head>\n <body>\n\n <div class='box'>\n <div class='btn'>X</div>\n </div>\n\n <script type=\"text/javascript\">\n var btn = document.querySelector('.btn');\n var box = document.querySelector('.box');\n btn.onclick = function(){\n box.style.display = 'none';\n }\n </script>\n </body>\n</html>\n","css":"/* html, body {\\n\\twidth: 100%;\\n\\theight: 100%;\\n\\tmargin: 0;\\n\\tpadding: 0;\\n} */","js":"// 请在这里输入代码"}
OPPO公司福利 1225人发布