<div id= "Time" style= "Border:solid 1px #ddd; Display:inline-block; width:50px; height:30px; Vertical-align:middle "></div>
<input type= "button" id= "BTN" value= "Stop" >
<script type= "Text/javascript" >//a timer, click the button to let him stop for a while, after 5s continue to run automatically varNum=0; vardata=1000; vartimeout=false; functionautoside () {num+=1; $("#time"). html (num);}vart=setinterval (Autoside,data); $ ("#btn"). Click (function() {T=clearinterval (t); varTimeout = SetTimeout (function() {T=setinterval (Autoside,data); },5000); }) </script>
The second way:
<DivID= "Time"style= "Border:solid 1px #ddd; display:inline-block; width:50px; height:30px; Vertical-align:middle"></Div><inputtype= "button"ID= "BTN"value= "Stop"><Scripttype= "Text/javascript"> varNum=0; varData= +; varTimeout=false; functiononum () {num++; $("#time"). html (num); } functionautoside () {if(timeout) {setTimeout (autoside, the); Timeout= 0; } Else{setTimeout (autoside, +); Onum (); }} $("#btn"). Click (function() {timeout= 1; }) Autoside ();</Script>
A timer, click the button to let him stop for a while, after 5s continue to run automatically