Simple time counter using Jquery

You can automate a task based on time using the JavaScript setInterval() function, which can be used to specify a regular time-based trigger.

counter_dark_timer

var elem = $('#' + id + ' #counter');
var count = 0;
myCounter = setInterval(function () {
    count += 1;
    elem.html(count);
}, 1000);

Code to Reset

clearInterval(myCounter);
$('#' + id + ' #jquery4ucounter').html('0');
Advertisements

One thought on “Simple time counter using Jquery

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s