关闭二维码
<style> .box { width: 300px; height: 100px; margin: 100px auto; position: relative; } img { width: 100px; height: 100px; } i { display: inline-block; margin: 10px; position: absolute; top: -50px; left: -50px; border: 10px solid grey; } </style> <div class="box"> <img src="images/p1.jpg"> <i class="close-btn">x</i> </div> <script> //获取事件源 var box = document.querySelector('.box'); var closebtn = document.querySelector('i'); //绑定事件,执行程序 closebtn.onclick = function () { //当我点击时隐藏box box.style.display = 'none'; } </script>
标签:box,100px,height,width,二维码,关闭,var,js From: https://www.cnblogs.com/doubleyancode/p/16791243.html