单击拒绝/关闭后禁用两个按钮
我的任务是在单击“拒绝”按钮后能够禁用批准和返回按钮。拒绝按钮意味着关闭项目。这些是我的代码。有人可以帮助我找出如何禁用按钮吗?
<div class="text-center ">
<button class="btn m-1 align-items-center btn-success text-center " id="approve">Approve</button>
<button class="btn btn-danger m-1 align-items-center text-center " id="clear" onclick="sweetalertrejects()">Reject</button>
<button class="btn btn-secondary m-1 align-items-center text-center" id="return">Return</button>
</div>
</div>
</div>
<script>
function sweetalertrejects(){
swal("This button means closing the task. You will not be able to revert this action. Do you wish to continue?", {
icon: "info",
buttons: {
cancel: "Cancel",
catch: {
text: "Yes, close this task",
value: "cancel",
},
},
})
.then((value) => {
switch (value) {
case "cancel":
swal("Closed!", "Task has been closed.", "success");
break;
default:
swal("Task has not been closed.");
}
});
}
</script>
My task is to be able to disable the approve and return buttons after clicking the reject button. Reject button means closing a project. These are my codes. Can anybody help me figure out how to disable the buttons?this is what the button looks like.
<div class="text-center ">
<button class="btn m-1 align-items-center btn-success text-center " id="approve">Approve</button>
<button class="btn btn-danger m-1 align-items-center text-center " id="clear" onclick="sweetalertrejects()">Reject</button>
<button class="btn btn-secondary m-1 align-items-center text-center" id="return">Return</button>
</div>
</div>
</div>
<script>
function sweetalertrejects(){
swal("This button means closing the task. You will not be able to revert this action. Do you wish to continue?", {
icon: "info",
buttons: {
cancel: "Cancel",
catch: {
text: "Yes, close this task",
value: "cancel",
},
},
})
.then((value) => {
switch (value) {
case "cancel":
swal("Closed!", "Task has been closed.", "success");
break;
default:
swal("Task has not been closed.");
}
});
}
</script>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以通过ID获取按钮并将其禁用如下:
这是整个代码
You can get the buttons by id and disable them as follows:
Here is whole code
您需要将className“ disable”包含在批准中&amp;返回按钮和您的JavaScript代码应该看起来像:
You need to include classname "disable" to the Approve & Return button and your javascript code should look like this: