简体   繁体   中英

How to use Public plugin methods

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

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();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM