憋死我了。
js jquery 实现点击按钮后,倒计时60秒才能再次点击发送验证邮件
在Spring mvc 中 用 <button class="btn btn-small btn-info btn-block" id="btn" type="button"
id="message">获取验证码</button>
button 不起作用 , 只能用 <input type="button" id="btn" class="btn btn-small btn-info btn-block" value="免费获取验证码" />
CSS文件后面的会覆盖前面的:如global.css会覆盖之前的样式表
JS文件后面的会引用前面的,如将global.js放在最开始,则会报一个找不到jQuery的错误,因此jQuery这种类库级的文件应该放到最开头。
js文件后面的会引用的前面的所以 自定义的需要放在 后面
好了,接下来是实现代码,
js:
var wait = 60;
function time(o) {
if (wait == 0) {
o.removeAttribute("disabled");
o.value = "免费获取验证码";
wait = 60;
} else {
o.setAttribute("disabled", true);
o.value = "重新发送(" + wait + ")";
wait--;
setTimeout(function() {
time(o);
}, 1000);
};
}
document.getElementById("btn").onclick = function() {
time(this);
};
jsp:<input type="button" id="btn" class="btn btn-small btn-info btn-block" value="免费获取验证码" />
新手,请大家多多指教