Files
ClassContent/历届学生/front-end-team-10/项目练习/上课项目/js 案例/index.html
2024-09-27 02:06:13 +08:00

66 lines
1.3 KiB
HTML

<!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>烦人的广告</title>
<style>
* {
margin: 0;
padding: 0;
}
body {
height: 3000px;
}
.gg {
width: 200px;
height: 200px;
background: red;
position: fixed;
right: 0;
bottom: 0;
}
.gg span {
position: absolute;
right: 10px;
top: 10px;
font-size: 20px;
cursor: pointer;
}
</style>
</head>
<body>
<div class="gg">
<span> x </span>
</div>
</body>
<script>
// 点击三次
// 第一次打开网页,第二次没什么反应,第三次关闭整个广告
var close = document.querySelector(".gg span"),
gg = document.querySelector(".gg"),
nums = 0;
close.onclick = () => {
nums += 1;
if (nums == 1) {
open("https://www.runoob.com/jsref/dom-obj-event.html")
}
// if (nums == 2) {
// }
if (nums == 3) {
gg.style.display = "none"
}
}
</script>
</html>