<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.box{
position: relative;
width: 200px;
height: 200px;
background-color: blueviolet;
margin: auto;
text-align: center;
font-size: 50px;
}
.box1{
position: absolute;
background-color: skyblue;
cursor: pointer; /*小手*/
}
</style>
</head>
<body>
<div class="box">
广告
<div class="box1">X</div>
</div>
<script>
// 1.事件源
const box1 = document.querySelector('.box1')
const box = document.querySelector('.box')
// 2.事件类型 点击鼠标 click 字符串
box1.addEventListener('click',function(){
box.style.display = 'none'
})
</script>
</body>
</html>
02-点击关闭
最新推荐文章于 2024-07-18 17:34:14 发布