46 lines
1.7 KiB
HTML
46 lines
1.7 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||
<title>Document</title>
|
||
</head>
|
||
<body>
|
||
<textarea name="" id="" cols="30" rows="10" readonly>
|
||
考试不及格,就要疯狂写代码,不写代码,就疯狂的打死
|
||
</textarea>
|
||
<input type="button" value="请在(10s)之后点击同意" disabled id="btn">
|
||
<input type="button" value="瓦达西,扣涂挖路" id="btn1">
|
||
<script type="text/javascript">
|
||
window.onload = function() {
|
||
var btn = document.getElementById('btn')
|
||
var btn1 = document.getElementById('btn1')
|
||
//控制value里边的时间,每隔1s变化一次 -1
|
||
var num = 10;
|
||
var timer1 = setInterval(function() {
|
||
num--;
|
||
btn.value = "请在("+ num +"s)之后点击同意"
|
||
//在num = 0 的时候清除定时器并改变按钮状态可点击,改变按钮的value
|
||
if(num <= 0) {
|
||
clearInterval(timer1);
|
||
//表单中属性名等于属性值,html表单可以简写
|
||
//js中操作属性时,值为Boolean
|
||
btn.disabled = false;
|
||
btn.value = '我同意';
|
||
}
|
||
}, 1000)
|
||
|
||
//时间结束之后将“我同意”置不可点击
|
||
btn1.onclick = function() {
|
||
setTimeout(function() {
|
||
if(num <= 0) {
|
||
btn.disabled = true;
|
||
}
|
||
},num*1000)
|
||
}
|
||
|
||
}
|
||
</script>
|
||
</body>
|
||
</html> |