首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在jquery步骤转换之间添加延迟(jquery步骤插件)

如何在jquery步骤转换之间添加延迟(jquery步骤插件)
EN

Stack Overflow用户
提问于 2017-08-12 17:26:42
回答 1查看 504关注 0票数 0

我使用的是http://www.jquery-steps.com/Examples#advanced-form插件。

如何在两个步骤之间添加延迟?

我曾尝试在onStepChangingonStepChanged中添加超时功能,但它不起作用。

下面是我的代码:

代码语言:javascript
复制
var form = $("#example-advanced-form").show();

form.steps({
    headerTag: "h3",
    bodyTag: "fieldset",
    transitionEffect: "slideLeft",
    onStepChanging: function (event, currentIndex, newIndex)
    {
        // Allways allow previous action even if the current form is not valid!
        if (currentIndex > newIndex)
        {
            return true;
        }
        // Forbid next action on "Warning" step if the user is to young
        if (newIndex === 3 && Number($("#age-2").val()) < 18)
        {
            return false;
        }
        // Needed in some cases if the user went back (clean up)
        if (currentIndex < newIndex)
        {
            // To remove error styles
            form.find(".body:eq(" + newIndex + ") label.error").remove();
            form.find(".body:eq(" + newIndex + ") .error").removeClass("error");
        }
        form.validate().settings.ignore = ":disabled,:hidden";
        return form.valid();
    },
    onStepChanged: function (event, currentIndex, priorIndex)
    {
        // Used to skip the "Warning" step if the user is old enough.
        if (currentIndex === 2 && Number($("#age-2").val()) >= 18)
        {
            form.steps("next");
        }
        // Used to skip the "Warning" step if the user is old enough and wants to the previous step.
        if (currentIndex === 2 && priorIndex === 3)
        {
            form.steps("previous");
        }
    },
    onFinishing: function (event, currentIndex)
    {
        form.validate().settings.ignore = ":disabled";
        return form.valid();
    },
    onFinished: function (event, currentIndex)
    {
        alert("Submitted!");
    }
}).validate({
    errorPlacement: function errorPlacement(error, element) { element.before(error); },
    rules: {
        confirm: {
            equalTo: "#password-2"
        }
    }
});
EN

回答 1

Stack Overflow用户

发布于 2017-08-12 18:57:30

这个怎么样?

代码语言:javascript
复制
setTimeout(function(){ /*your function*/ }, 3000);

https://www.w3schools.com/JSREF/met_win_setTimeout.asp

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45648661

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档