Jquery 禁用“下一步”按钮直到动画完成

发布于 2024-09-17 05:35:34 字数 87 浏览 4 评论 0原文

这很酷,我对此很熟悉。不过,我希望下一个和上一个按钮保持可见,只是不能单击。在我的特定情况下,按钮是属于设计一部分的图像。我只是希望用户在动画结束之前无法点击。

This is cool and I am familiar with this. However I want the next and previous buttons to stay visible, just not be click able. In my particular situation, the buttons are images that are part of the design. I just want the user to not be able to click through before an animation ends.

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

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

发布评论

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

评论(5

菩提树下叶撕阳。 2024-09-24 05:35:34
$(function(){
    $("#previous").bind("click", Previous);
    $("#next").bind("click", Next);
});

function DoAnimation() {
    $("#previous,#next").unbind("click");
    $('#id').animate(
        complete: function() {
            $(this).after('<div>Animation complete.</div>');
            $("#previous").bind("click", Previous);
            $("#next").bind("click", Next);
        }
    });
}

function Previous() { }
function Next() { }
$(function(){
    $("#previous").bind("click", Previous);
    $("#next").bind("click", Next);
});

function DoAnimation() {
    $("#previous,#next").unbind("click");
    $('#id').animate(
        complete: function() {
            $(this).after('<div>Animation complete.</div>');
            $("#previous").bind("click", Previous);
            $("#next").bind("click", Next);
        }
    });
}

function Previous() { }
function Next() { }
夜司空 2024-09-24 05:35:34

另一种技术:

$(".next,.prev").click(function(){
    if ($('#my_animated_elelement').is(':animated'))
    {
        return false;
    }
})

one more technique:

$(".next,.prev").click(function(){
    if ($('#my_animated_elelement').is(':animated'))
    {
        return false;
    }
})
厌倦 2024-09-24 05:35:34

我猜您对图像 onclick 有 javascript 调用,请使用变量 MyApp.IgnoreNextPrevClicks 来标记 onclick 处理程序是否执行。

MyApp={}
MyApp.IgnoreNextPrevClicks=false;
MyApp.PrevClick=function() {
    if(MyApp.IgnoreNextPrevClicks) return;
    //real work goes here
}

现在,在调用 jquery 动画制作器之前,将 MyApp.IgnoreNextPrevClicks 设置为 true,并在动画结束后将其设置回 false(使用 jquery 动画回调)。

I guess you have javascript calls for the images onclick's, use a variable MyApp.IgnoreNextPrevClicks to flag whether the onclick handlers do execute or not.

MyApp={}
MyApp.IgnoreNextPrevClicks=false;
MyApp.PrevClick=function() {
    if(MyApp.IgnoreNextPrevClicks) return;
    //real work goes here
}

now before calling the jquery animator, set MyApp.IgnoreNextPrevClicks to true, and set it back to false after the animation ends (use jquery animation callback).

旧人哭 2024-09-24 05:35:34
function btn() {
   $('#btn').one('click', function(){
     //call your animation function here.

     setTimeout(btn, animation duration);
  });
}
function btn() {
   $('#btn').one('click', function(){
     //call your animation function here.

     setTimeout(btn, animation duration);
  });
}
番薯 2024-09-24 05:35:34
$('#mybtn').attr("disabled","disabled"); // to Disable Button

$('#mybtn').removeAttr("disabled"); // to Enable Disabled button
$('#mybtn').attr("disabled","disabled"); // to Disable Button

$('#mybtn').removeAttr("disabled"); // to Enable Disabled button
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文