Stop the execution of the setinterval () Timer function:
This section describes how to stop the operation of the timer function, hoping to bring help to the needy friends.
The use of the SetInterval () function can be found in the Window.setinterval () method section.
Special Note: the timer setinterval () function returns a unique identity that is performed by the current function each time the execution occurs.
Use the Clearinterval () function to stop the execution of the timer function, and the parameter is the identity returned by the SetInterval () function.
code example:
<!DOCTYPE HTML><HTML><Head><MetaCharSet= "Utf-8"><Metaname= "Author"content= "http://www.softwhy.com/" /><title>Ant Tribe</title><Scripttype= "Text/javascript">window.onload=function(){ varOBT=document.getElementById ("BT"); varOdiv=document.getElementById ("Atnzone"); varNum=0; varTimer=NULL; functioncount () {num=Num+1; Odiv.innerhtml=num; } Timer=setinterval (Count, +); Obt.onclick=function() {clearinterval (timer); }}</Script></Head> <Body> <DivID= "Atnzone"></Div><inputtype= "button"ID= "BT"value= "View Effect"/></Body> </HTML>
In the above code, the identifier of the setinterval () function is a timer, each call produces a unique representation, as long as the clearinterval () function is used, and the parameter is set to the corresponding timer function's identity to stop the corresponding timer function execution.
The original address is: Stop the execution of the setinterval () Timer function section.
Stop the execution of the setinterval () Timer function