点击按钮后我们可以禁用HTML上的按钮吗? [英] Can we disable button on HTML after clicking on button?
问题描述
当我们加载页面按钮时应禁用5秒。
之后将启用,当我们点击按钮时必须带我们到特定链接。(onclick)
一旦我们再次点击按钮按钮应该被禁用。
我尝试了什么:
i已尝试低于一个
1.当我们加载页面按钮时应该禁用5秒。
2.之后将启用,当我们点击按钮时,必须带我们到特定链接。(onclick)
when we are loading a page button should be disable for 5 sec.
after that that will enable, when we click on button that has to take to us to particular link.(onclick)
once we click on button again button should be disabled.
What I have tried:
i have tried below one
1.when we are loading a page button should be disable for 5 sec.
2.after that that will enable, when we click on button that has to take to us to perticular link.(onclick)
<input type="submit" id="submitButton" disabled="disabled" />
<script type="text/javascript">
window.onload=function() {
setTimeout(function() {
document.getElementById('submitButton').disabled = false;
}, 5000);
}
</script>
之后,当我们点击必须使用diasble的按钮时没有发生使用上面的代码
after that when we clicked on button that has to diasble that is not happening by using above code
推荐答案
你可以试试这样的事情
You could try something like this
<script>
document.getElementById("submitButton").addEventListener("click", myFunction);
function myFunction() {
document.getElementById('submitButton').disabled = true;
}
</script>
这篇关于点击按钮后我们可以禁用HTML上的按钮吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!