<! DOCTYPE html>
<meta charset= "utf-8" >
<title>100s Countdown </title>
<style>
body,div{margin:0;padding:0;}
Body{color: #fff; font:16px/1.5 \5fae\8f6f\96c5\9ed1;}
#countdown {width:300px;text-align:center;background: #000; margin:10px auto;padding:20px 0;}
Input{border:0;width:283px;height:50px;cursor:pointer;margin-top:20px;background:url (
) no-repeat;}
input.cancel{background-position:0 -50px;}
Span{color: #000; width:80px;line-height:2;background: #fbfbfb; border:2px solid #b4b4b4; margin:0 10px;padding:0 10px;}
</style>
<script>
Window.onload = function () {
var ocount = document.getElementById (' Countdown '),
Oinput = ocount.getelementsbytagname (' input ') [0],
Aspan = Ocount.getelementsbytagname (' span '),
Timer = null;
Oinput.addeventlistener (' Click ', function () {
This.classname = = '? (timer = setinterval (updatetime,1000)): clearinterval (timer);
This.classname = This.classname = = = ' Cancel '? ': ' Cancel ';
},false);
function Format (a) {
return a.tostring (). replace (/^ (\d) $/, ' 0$1 ');
}
function UpdateTime () {
Console.log (aspan[0].innerhtml);
var remain = parseint (aspan[0].innerhtml.replace (/^0/, ')) *60+parseint (aspan[1].innerhtml.replace (/^0/, '));
If (remain <= 0) {
Clearinterval (timer);
Return
}
remain--;
aspan[0].innerhtml = Format (parseint (remain/60));
aspan[1].innerhtml = Format (remain%60);
}
}
</script>
<body>
<div id= "countdown" >
<span>01</span> minutes <span>40</span> seconds
<input type= "button" value= ""/>
</div>
</body>
Welcome to join 618237474, Find a group of private chat, send a huge amount of study materials free to send
JS for 100 seconds countdown and simple clock