[英]how to disable a submit button for 10 seconds after the page is loaded
My question is probably simple, but I'm only a week into programming, and I cant really understand the relative answers that I could find. 我的问题可能很简单,但是我只需要一个星期的编程时间,就无法真正理解相对的答案。 So... need your Jedi help.
所以...需要您的绝地帮助。 How to disable a submit button for 10 seconds after the page is loaded?
页面加载后如何禁用提交按钮10秒钟? Thanks!
谢谢!
You can use javascript like this 您可以像这样使用javascript
<input type="submit" id="submitButton" disabled="disabled" />
using 运用
<script type="text/javascript">
window.onload=function() {
setTimeout(function(){
document.getElementById('submitButton').disabled = null;
},10000);
}
</script>
The following will additionally show a countdown in a container with ID="timeLeft" if you need one 如果需要,下面还会显示一个ID为“ timeLeft”的容器中的倒计时
<script type="text/javascript">
var countdownNum = 10;
window.onload=function() {
incTimer();
}
function incTimer(){
setTimeout (function(){
if(countdownNum != 0){
countdownNum--;
document.getElementById('timeLeft').innerHTML = 'Time left: ' + countdownNum + ' seconds';
incTimer();
} else {
document.getElementById('submitButton').disabled = null;
document.getElementById('timeLeft').innerHTML = 'Ready!';
}
},1000);
}
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.