I. setinterval ()/clearinterval () Technical Learning
Are all methods of the Window object and can be used directly.
SetInterval (function () {},1000);: Executes functions every 1000 milliseconds;
Clearinterval (item);: Clears the setting of the SetInterval () function, where item is the return object of SetInterval (), for example: var item = setinterval ();
Second, the page timer
In the HTML page:
Embed JS code inside the page:
<script type= "Text/javascript" > $(function(){ varSEC = 0; varMin = 0; varHour = 0; varSecstr; varMinstr; varHourstr; Curtime= SetInterval (function() {sec= Sec+1; if(Sec > 59) {min= min + 1; SEC= 0; if(Min > 59) {Hour= Hour + 1; Min= 0; }} secstr= sec < 10? " 0 "+sec:sec; Minstr= Min < 10? " 0 "+min:min; Hourstr= Hour < 10? " 0 "+Hour:hour; $(". Time"). HTML (hourstr+ ":" +minstr+ ":" +secstr); },1000); $(". Stop a"). Click (function() {window.clearinterval (curtime);//Curtime must be passed in to the method as a parameter }); });</script>JS function: SetInterval ()/clearinterval ()--JS Web Timer