html+javascript简易倒计时(分,秒)
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> </head> <body> <p id="jishi">2</p> <button id="jishi" onclick="djs()">开始</button> <p></p> <span>剩余时间:</span> <span id="fen"></span><span> :</span> <span id="miao">00</span> <script type="text/javascript"> var starttime=document.getElementById("jishi").innerText; document.getElementById("fen").innerText=starttime; function djs(){ var mtime=document.getElementById("fen").innerText; var stime=document.getElementById("miao").innerText; if(mtime==0 && stime==0){ return ; } stime--; if(mtime>0 && stime==-1){ mtime--; stime=59; } if(stime<10){ stime='0'+stime; } setTimeout("djs()",1000); document.getElementById("fen").innerText=mtime; document.getElementById("miao").innerText=stime; } </script> </body> </html>
截图:
有空再完善