如何制作点击短信发送功能的计时器?
- 内容介绍
- 文章标签
- 相关推荐
本文共计78个文字,预计阅读时间需要1分钟。
<input type="button" id="btn" value="发送短信"> <script type="text/javascript" src="/jquery/jquery.js"> var count_time= 60;//定义规定的时间,60秒后再次发送 function start_timer() { if(count_time == 0) { $('#btn').removeAttr("disabled"); $('#btn').val("重新发送"); count_time= 60; }else { $('#btn').attr("disabled",true); $('#btn').val("重新发送("+count_time+")"); count_time--; setTimeout(function(){start_timer();},1000); } } $('#btn').click(function(){ start_timer(); }); </script>
本文共计78个文字,预计阅读时间需要1分钟。
<input type="button" id="btn" value="发送短信"> <script type="text/javascript" src="/jquery/jquery.js"> var count_time= 60;//定义规定的时间,60秒后再次发送 function start_timer() { if(count_time == 0) { $('#btn').removeAttr("disabled"); $('#btn').val("重新发送"); count_time= 60; }else { $('#btn').attr("disabled",true); $('#btn').val("重新发送("+count_time+")"); count_time--; setTimeout(function(){start_timer();},1000); } } $('#btn').click(function(){ start_timer(); }); </script>

