我们可以从函数外部结束Jquery中的回调函数吗

发布于 2024-09-08 11:06:36 字数 229 浏览 0 评论 0原文

我正在使用 David Walsh 的 time-ticker 函数。每当我必须创建一个新实例并完全编写一个新实例时,我确实设法从回调函数中返回 false。但如果我能以某种方式更新其中的回调函数形式,那么代码将会更加干净。请让我知道,即使是更一般的事情。提前致谢 :)

I am using the time-ticker function by David Walsh. I did manage to return false from within the callback function, whenever I had to create a new instance, and wrote a new instance altogether. But it would be far more clean code if I could somehow update the call back function form within. Please let me know, even if it is something more general. Thanks in advance :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

榆西 2024-09-15 11:06:36

您可以提供您喜欢的任何回调...这是设置之一 - 所以如果您想结束回调,您只需返回即可。

$('#countdown').countDown({
    startNumber: 10,
    callBack: function(me) {
        $(me).text('All done! This is where you give the reward!').css('color','#090');
        alert("You can do anything here");
        // Including calling another function
        DoSomething();
        return false;
    }
});

You can supply whatever callback you like... it is one of the settings - so if you wanted to end the callback, you just need to return out of it.

$('#countdown').countDown({
    startNumber: 10,
    callBack: function(me) {
        $(me).text('All done! This is where you give the reward!').css('color','#090');
        alert("You can do anything here");
        // Including calling another function
        DoSomething();
        return false;
    }
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文