<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>計時器</title> </head> <body> <button id="setTime">免費發送短信</button> <script type="text/javascript" src="jquery.min.js"></script> <script type="text/javascript"> var time=10; $(document).ready(function(){ $("#setTime").click(function(){ $(this).attr("disabled","disabled"); var span="秒後免費發送短信"; $(this).html(time+span); var t=setInterval(function(){ time=time-1; if(time==0){ $("#setTime").html("免費發送短信"); $("#setTime").removeAttr("disabled"); time=10; clearInterval(t); }else{ $("#setTime").html(time+span); } },1000) }) }) </script> </body> </html>
計時器應用
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.