pink老师 APls Day2
思路:
- 建立一个点击事件
- 按钮(button)与广告的关系
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.box {
position: relative;
width: 500px;
height: 200px;
background-color: pink;
margin: 100px auto;
text-align: center;
font-size: 30px;
line-height: 200px;
font-weight: 700;
}
</style>
</head>
<body>
<div class="box">
我是广告
<button>×</button>
</div>
<script>
// 获取按钮、广告(div盒子)
const btn = document.querySelector('button')
const box = document.querySelector('.box')
// 对按钮进行点击后 隐藏广告(div盒子)
btn.addEventListener('click', function() {
box.style.display = 'none'
})
</script>
</body>
</html>