英文:
how to disable a button permanently after clicking it in jsp
问题
如何在单击按钮后永久禁用它?即使在刷新页面后它仍然应该保持禁用状态。但是在刷新页面后,按钮又变为启用状态。如何做到这一点?
英文:
how to disable a button permanently after clicking it ?it should remain disabled after refreshing the page also.But after refreshing the page the button is enabled again.how to do this??
答案1
得分: 1
以下是您要求的翻译内容:
其实非常简单,只需将 disabled 属性更改为 true。
<script type="text/javascript">
function disableButton(btn){
document.getElementById(btn.id).disabled = true;
alert("按钮已被禁用。");
}
</script>
使用 HTML,它看起来会是这样的:
<!--JavaScript - 在点击后使用 JavaScript 函数禁用按钮。-->
<html>
<head>
<title>JavaScript - 在点击后使用 JavaScript 函数禁用按钮。</title>
<script type="text/javascript">
function disableButton(btn){
document.getElementById(btn.id).disabled = true;
alert("按钮已被禁用。");
}
</script>
</head>
<body style="text-align: center;">
<h1>JavaScript - 在点击后使用 JavaScript 函数禁用按钮。</h1>
<p><input type="button" id="btn1" value="点击以禁用按钮。" onclick="disableButton(this)"></p>
</body>
</html>
英文:
its really easy , just change disabled property to true..
<script type="text/javascript">
function disableButton(btn){
document.getElementById(btn.id).disabled = true;
alert("Button has been disabled.");
}
</script>
with HTML it would look smth like this
<!--JavaScript - Disable Button after Click using JavaScript Function.-->
<html>
<head>
<title>JavaScript - Disable Button after Click using JavaScript Function.</title>
<script type="text/javascript">
function disableButton(btn){
document.getElementById(btn.id).disabled = true;
alert("Button has been disabled.");
}
</script>
</head>
<body style="text-align: center;">
<h1>JavaScript - Disable Button after Click using JavaScript Function.</h1>
<p><input type="button" id="btn1" value="Click to disable button." onclick="disableButton(this)"</p>
</body>
</html>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论