AdBlock Detected

We provide high-quality source code for free. Please consider disabling your AdBlocker to support our work.

Buy me a Coffee

Saved Tutorials

No saved posts yet.

Press Enter to see all results

How to Start count and Brack timer clearTimeout() in Jquery

By pushpam abhishek
Listen to this article
Start count and Brack timer clearTimeout() in Jquery


Enable break times in Jquerycountdown timer

In these articles, we will learn How to  Start count and Brack timer clearTimeout() in JqueryEnable break times in Jquerycountdown timer.


<!DOCTYPE html>
<html>
<body>

<button onclick="startCount()">Start count!</button>
<input type="text" id="txt">
<button onclick="stopCount()">Stop count!</button>

<p>
Click on the "Start count!" button above to start the timer. The input field will count forever, starting at 0. Click on the "Stop count!"
<br/> button to stop the counting. Click on the "Start count!" button to start the timer again.
</p>

<script>
var c = 0;
var t;
var timer_is_on = 0;
var myCounter = 0;

function timedCount() {
  document.getElementById("txt").value = c;
  c = c + 1;  
  
  t = setTimeout(timedCount, 1000);
  myCounter = myCounter + 1
   if(myCounter == 100)
    {
     c = 0;
     t;
     timer_is_on = 0;
     myCounter = 0;
    clearTimeout(t);
   timer_is_on = 0;
    }
   
}

function startCount() {
  if (!timer_is_on) {
    timer_is_on = 1;
    timedCount();
  
   
  }
}

function stopCount() {
 c = 0;
 t;
 timer_is_on = 0;
 myCounter = 0;
  clearTimeout(t);
  timer_is_on = 0;
}
</script>

</body>
</html>

OutPut:-

Enable break times in Jquerycountdown timer

Share this post

pushpam abhishek

About pushpam abhishek

Pushpam Abhishek is a Software & web developer and designer who specializes in back-end as well as front-end development. If you'd like to connect with him, follow him on Twitter as @pushpambhshk

Comments