60 lines
1.2 KiB
HTML
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> |