分析
- 核心思路:5秒之后把广告隐藏起来
- 定时器setTimeout()
代码
<html>
<head>
<meta charset="utf-8">
<title>5秒后自动关闭</title>
<style>
img {
}
</style>
</head>
<body>
<img src="./image/微信截图_20201201231713.png" alt="5秒后自动关闭" class="ad">
<script>
var ad = document.querySelector('.ad');
setTimeout(function() {
ad.style.display = 'none';
}, 5000);
</script>
</body>
</html>