Reputation: 2591
I am using jQuery timer that start on init function using this script
var Example1 = new(function () {
var $stopwatch, // Stopwatch element on the page
incrementTime = 70, // Timer speed in milliseconds
currentTime = 0, // Current time in hundredths of a second
updateTimer = function () {
$stopwatch.html(formatTime(currentTime));
currentTime += incrementTime / 10;
},
init = function () {
$stopwatch = $('#stopwatch');
Example1.Timer = $.timer(updateTimer, incrementTime, true);
};
this.resetStopwatch = function () {
currentTime = 0;
this.Timer.stop().once();
};
$(init);
});
I want to start time when user click on button I am using example 1 stop watch http://jchavannes.com/jquery-timer/demo
I want it to be work when user clik on other button except on page load
Upvotes: 0
Views: 79
Reputation: 43479
Use jQuery click
event:
$('button').click(function(){
var $stopwatch,
incrementTime,
/* */
});
Upvotes: 1