关闭二维码
2019-05-10 本文已影响0人
椋椋夜色
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title> 关闭二维码 </title>
<style>
.box {
width: 107px;
height: 127px;
position: fixed;
left: 50%;
top: 50%;
margin-left: -53.5px;
margin-top: -63.5px;
border: 1px solid #d9d9d9;
}
span {
width: 15px;
height: 15px;
position: absolute;
left: -16px;
top: 0;
border: 1px solid #d9d9d9;
font-size: 12px;
text-align: center;
line-height: 15px;
color: #d9d9d9;
cursor: pointer;
}
</style>
</head>
<body>
<div class="box">
<img src="../images/taobao.jpg" alt="">
<span id="close">X</span>
</div>
<script>
//给span加点击事件
document.getElementById('close').onclick = function () {
// parentNode 找到父节点
this.parentNode.style.display = "none";
};
</script>
</body>
</html>