gpt4 book ai didi

html - 如何通过单击另一个按钮来启用禁用的按钮?

转载 作者:太空宇宙 更新时间:2023-11-04 13:38:26 25 4
gpt4 key购买 nike

我有两个按钮:

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

关于html - 如何通过单击另一个按钮来启用禁用的按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17584515/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com