点击后
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
body {
padding: 40px;
}
ul {
padding: 0;
list-style: none;
}
li {
margin: 10px 0;
line-height: 26px;
display: flex;
}
input,
button {
padding: 0;
margin-left: 10px;
display: block;
}
input {
width: 190px;
outline: none;
}
button {
width: 120px;
}
.verify {
width: 60px;
}
</style>
</head>
<body>
<ul>
<li>
您的血脉:
<input type="text">
</li>
<li>
变身类型:
<input type="text" class="verify">
<button id="btn">变成光!</button>
</li>
</ul>
<script>
let btn = document.getElementById('btn')
btn.addEventListener('click', function () {
this.disabled = true
let i = 6
btn.innerText = `收到召唤,等待变身(${i})!`
let stop = setInterval(
function () {
i--
btn.innerText = `收到召唤,等待变身(${i})!`
if (i === 0) {
clearInterval(stop)
btn.disabled = false
btn.innerText = `再次变成光!`
}
}, 1000)
})
</script>
</body>
</html>