简体   繁体   English

如何在jsp中单击按钮后永久禁用按钮

[英]how to disable a button permanently after clicking it in jsp

单击后如何永久禁用按钮?刷新页面后它也应保持禁用状态。但刷新页面后,该按钮再次启用。如何执行此操作?

its really easy , just change disabled property to true..它真的很简单,只需将 disabled 属性更改为 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使用 HTML 它看起来像这样

<!--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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM