This article mainly introduces the digital countdown effect of JS web pages. it is a very practical javascript countdown effect and has some reference value, if you need it, refer to the example in this article to describe the digital clock effect of the webpage countdown implemented by JS. Share it with you for your reference. The specific implementation method is as follows:
The code is as follows:
Countdown clock implemented by javascript
Script
Window. onload = function ()
{
Var oCountDown = document. getElementById ("countdown ");
Var aInput = oCountDown. getElementsByTagName ("input") [0];
Var timer = null;
AInput. onclick = function ()
{
This. className = ""? (Timer = setInterval (updateTime, 1000), updateTime (): (clearInterval (timer ));
This. className = this. className = ''? "Cancel ":'';
};
Function format ()
{
Return a. toString (). replace (/^ (\ d) $/, '0 $1 ')
}
Function updateTime ()
{
Var aSpan = oCountDown. getElementsByTagName ("span ");
Var oRemain = aSpan [0]. innerHTML. replace (/^ 0/, '') * 60 + parseInt (aSpan [1]. innerHTML. replace (/^ 0 /,''));
If (oRemain <= 0)
{
ClearInterval (timer );
Return
}
ORemain --;
ASpan [0]. innerHTML = format (parseInt (oRemain/60 ));
ORemain % = 60;
ASpan [1]. innerHTML = format (parseInt (oRemain ));
}
}
Script
01 minutes, 40 seconds
Script home www.jb51.net code special effect
I hope this article will help you design javascript programs.