I was playing with this code (https://github.com/rendro/countdown) and I was wondering how I should use "Public plugin methods" (as listed in the readme.md).
Specifically, I am launching a countdown timer like this:
function Timer(minutes) {
$('.countdown').countdown({
date: new Date().getTime() (1000 * 60 * minutes - 1000),
render: function(data) {
$(this.el).text(this.leadingZeros(data.min) ":" this.leadingZeros(data.sec, 2));
});
}
// Launch timer
Timer(2);
And now I am trying to use the "stop()" method, but can't figure out how I should be doing it.
I tried $('.countdown').countdown.sop()
, then I tried countdown.stop()
, then I tried using var timer = Timer(2)
followed by timer.stop()
I just don't know how I should be using these methods.
Any help greatly appreciated, as the repo is inactive now.
Thanks
CodePudding user response:
it bind object to element by data. if you want to stop it, please first get the object and then stop, like below code:
$('.countdown').data('countdown').stop();