<!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>Document</title>
<style>
#model{
width: 200px;
height: 200px;
margin: auto;
top: 0;
bottom: 0;
left: 0;
right: 0;
position: absolute;
background-color: antiquewhite;
}
#button{
width: 200px;
height: 50px;
margin-top: 150px;
text-align: center;
line-height: 50px;
cursor: pointer;
background-color: aquamarine;
}
</style>
</head>
<body>
<div id="model">
<div id="button">确认10s</div>
</div>
</body>
<script>
let button = document.getElementById('button')
let model = document.getElementById('model')
let number = 10
button.onclick =function(){
clearInterval(int)
model.style.display='none'
}
function clock(){
number>0?number--:close()
number===0?button.innerHTML = '确认':button.innerHTML = '确认'+number+'s'
}
function close(){
clearInterval(int)
model.style.backgroundColor='red'
}
var int = setInterval('clock()',1000)
</script>
</html>
简易的倒计时盒子设计
最新推荐文章于 2024-07-24 20:11:59 发布