javascript - Stop countdown when it reaches to "0" -


i want stop counter when reaches 0, can me?

function countdown() {     var = document.getelementbyid('counter');     if (parseint(i.innerhtml)<=0) {     }     i.innerhtml = parseint(i.innerhtml)-1; } setinterval(function(){ countdown(); },1000); 

<html > <head>   <meta http-equiv="content-type" content="text/html; charset=utf-8" /> </head> <body> <div id="counter">5</div>  <script type="text/javascript"> function countdown() {     var = document.getelementbyid('counter');     i.innerhtml = parseint(i.innerhtml)-1;     if (parseint(i.innerhtml)==0) {        clearinterval(timerid);     } } var timerid = setinterval(function(){ countdown(); },1000); </script> </body> </html> 

Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -