Bladephp: Now with 8+ codeigniter, php, and laravel project 8+ php project From $37/Month From Rs. 2499/Month

How to Interval Timer Countdown using setTimeout()

by
Category:javascript
ajax javascript
How to Interval Timer Countdown using setTimeout()

window.setTimeout() allows you to specify that a piece of JavaScript code (called an expression) will be run a specified number of milliseconds from when the setTimeout() method was called. You may also like How to converting pacific time string to time in PHP and How to get Page Loading Time using PHP.

HTML Code

<input id="timer_count" type="text">

Jquery Code

var i = 0;
var myVar;
function onTimer() {
    $('#timer_count').val(i);
    i++;
    myVar = setTimeout(onTimer, 1000);
} 
onTimer();

function ClearTime()
{
    i = 0;
    clearTimeout(myVar);
    onTimer();
}

0 Comments


Html code work in comment box


Related Post