Javascript jQuery:单击10分钟后禁用按钮

Javascript jQuery:单击10分钟后禁用按钮,javascript,jquery,Javascript,Jquery,我想在点击按钮10分钟后禁用它。我正在使用这段代码,如果没有添加delay(),它就会工作。但迟迟不见成效 <script> $(".selected-button").delay(600000).attr({ disabled: true, title: "You have already chosen the best answer and now you can not change it!" }); </script> $(“.selected

我想在点击按钮10分钟后禁用它。我正在使用这段代码,如果没有添加delay(),它就会工作。但迟迟不见成效

<script>
$(".selected-button").delay(600000).attr({
    disabled: true,
    title: "You have already chosen the best answer and now you can not change it!"
});
</script>

$(“.selected button”).delay(600000).attr({
残疾人:对,,
标题:“您已经选择了最佳答案,现在您无法更改它!”
});

您可以尝试使用
setTimeout
执行类似操作:

$(".selected-button").click(function() {
    var $this = $(this);
    $this.attr("disabled", true);
    setTimeout(function() {
        $this.removeAttr("disabled");      
    }, 600000);
});

要在单击10分钟后禁用按钮,请执行以下操作:

$(".selected-button").click(function() {
    $.ajax({
        type: 'POST',
        url: url,
        data: data,
        done: function (data) {
            if (data.status === 'OK') {
                var that = $(this);
                setTimeout(function() {
                    that.prop("disabled", true);
                }, 10*60*1000);
            }
        }
    });
});

例如5s。

您可以使用setTimeout
.delay()
仅对动画等效果有效。@JatinSoni单击10分钟后,该按钮将被禁用。您希望何时启动它?@JatinSoni编辑,如果您希望仅在ajax成功响应后禁用按钮。我刚刚意识到这一点,因为我在Satpal的回复中看到了你的评论。请更新您的问题,让我们清楚地了解此信息!!(标题应为“ajax调用后禁用”)