很好用的发送短信倒计时JS代码
发布时间:2015-10-15, 12:02:57 分类:HTML | 编辑 off 网址 | 辅助
正文 1052字数 186,050阅读
<body>
<button id="btn" style="width:70px;">发送</button>
</body>
<script type="text/javascript">
var test = {
node:null,
count:60,
start:function(){
//console.log(this.count);
if(this.count > 0){
this.node.innerHTML = this.count--;
var _this = this;
setTimeout(function(){
_this.start();
},1000);
}else{
this.node.removeAttribute("disabled");
this.node.innerHTML = "再次发送";
this.count = 60;
}
},
//初始化
init:function(node){
this.node = node;
this.node.setAttribute("disabled",true);
this.start();
}
};
var btn = document.getElementById("btn");
btn.onclick = function(){
alert("发送成功...");
test.init(btn);
};
</script>
Run code
Cut to clipboard
(支付宝)给作者钱财以资鼓励 (微信)→
暂无评论 »