Stop the execution of the setinterval () Timer function

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.