Today I am reading a blog post on the css exploration journey. I wrote a timer bomb using setTimeout, and I will write it as a cat. & Lt ;! DOCTYPEhtmlPUBLIC & quot;-// W3C // DTDXHTML1.0Transitional // EN & quot; http://www.w3.org/TR/xhtml1/DTD ..
Today I am reading a blog post on the css exploration journey. I wrote a timer bomb using setTimeout, and I will write it as a cat.
Untitled document
Start timing
Bomb Removal
Script
$ ("# Zha"). bind ("click", function (){
Zha ();
})
$ ("# Chai"). bind ("click", function (){
Chai ();
})
Var time = 5;
Var timer = 0;
Function zha (){
Var text = "Countdown ";
Text + = time --;
$ ("# Zha"). text (text );
If (time> = 0 ){
Timer = setTimeout (zha, 1000 );
$ ("# Zha" ).css ("color", "black ");
$ ("# Chai"). show ();
} Else {
$ ("# Zha"). text ("explosion ");
$ ("# Zha" ).css ("color", "red ");
Time = 5;
$ ("# Chai"). fadeOut ();
}
}
Function chai (){
ClearTimeout (timer );
$ ("# Zha"). text ("the bomb has been removed successfully, click Continue ");
}
Script
From jingangel