【问题标题】:How to enable a disabled button by clicking on another button?如何通过单击另一个按钮来启用禁用的按钮?
【发布时间】:2013-07-09 04:50:34
【问题描述】:

我有两个按钮:

<button onclick=initialize() id="1" data-role="button" data-mini="true" data-corners="false" data-theme="b">Show My Position</button>
<button onclick=calcRoute() id="2" data-role="button" data-mini="true" data-corners="false" data-theme="b">Evacuate !</button>

我希望默认禁用第二个按钮,并在单击第一个按钮时启用它。我该如何做到这一点?

【问题讨论】:

    标签: html button ibm-mobilefirst


    【解决方案1】:

    请查看以下问题的答案:

    最简单的方法是(只是一个纯粹的例子,不考虑浏览器等):

    <html>
    <head>
        <script>
            function enableButton2() {
                document.getElementById("button2").disabled = false;
            }
        </script>
    </head>
    <body>
        <input type="button" id="button1" value="button 1" onclick="enableButton2()"  />
        <input type="button" id="button2" value="button 2" disabled />
    </body>
    </html>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-08
      • 2016-07-15
      相关资源
      最近更新 更多