Files
ClassContent/历届学生/front-end-team-10/项目练习/学生项目/韩孟雪/2023-2-25/js案例1_关闭弹窗.html
2024-09-27 02:06:13 +08:00

60 lines
1.2 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>js案例_关闭弹窗</title>
<style>
.box {
width: 200px;
height: 200px;
background: red;
position: fixed;
right: 0;
bottom: 0;
}
.box span {
font-size: 14px;
color: #000;
position: absolute;
top: 13px;
right: 6px;
user-select: none;
cursor: pointer;
}
</style>
</head>
<body>
<div class="box">
<span>X</span>
</div>
</body>
<script>
function alter() {
var i = 0;
$("span").onclick = () => {
i++
if (i == 1) {
open("https://www.baidu.com/")
}
if (i == 3) {
$(".box").style.display = "none";
}
}
}
alter();
function $(className) {
return document.querySelector(className);
}
function _(className) {
return document.querySelectorAll(className);
}
</script>
</html>