<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
.box {
position: relative;
width: 74px;
height: 88px;
border: 1px solid #ccc;
margin: 100px auto;
text-align: center;
font-size: 12px;
color: #f40;
}
.box img {
width: 60px;
margin-top: 5px;
}
.close-btn {
position: absolute;
top: -1px;
left: -16px;
width: 14px;
border: 1px solid #CCC;
line-height: 14px;
font-family: arial, helvetica, sans-serif;
cursor: pointer;
color: #CCCCCC;
}
</style>
</head>
<body>
<div class="box">
广告
<img src="../apiimg/广告.png" alt="">
<i class="close-btn">x</i>
</div>
<script type="text/javascript">
//获取元素
var btn = document.querySelector('.close-btn');
var box = document.querySelector('.box');
//注册事件 程序处理
btn.onclick = function() {
box.style.display = 'none'; //隐藏div
}
</script>
</body>
</html>
点击关闭广告
最新推荐文章于 2021-06-22 22:49:12 发布