gpt4 book ai didi

javascript - html输入框消失

转载 作者:行者123 更新时间:2023-12-03 02:07:52 25 4
gpt4 key购买 nike

我有这个简单的 html 表单。有 3 个单选框选项。最后一个单选框选项是“其他”我希望输入其他原因的文本框仅在选择“其他”组合框时才出现。有什么办法可以做到这一点吗?

<html>
<body>
<div class="form-group">

<input type="radio" name="option" value="a"> Missing deadline.<br>
<input type="radio" name="option" value="b"> Unsatisfied with the work.<br>
<input type="radio" name="option" value="c"> No response from Accountant.<br>
<input type="radio" name="option" value="d"> Other reasons. <br>

<input autofocus type="text" id="reason" name="reason" placeholder="Please key in the reasons.">

</div>
<body>
</html>

最佳答案

尝试一下。

function showTextbox() {
document.getElementById("reason").style.display = "block";
}
<html>

<body>
<div class="form-group">

<input type="radio" name="option" value="a"> Missing deadline.<br>
<input type="radio" name="option" value="b"> Unsatisfied with the work.<br>
<input type="radio" name="option" value="c"> No response from Accountant.<br>
<input type="radio" name="option" value="d" onclick="showTextbox()"> Other reasons. <br>


<input autofocus type="text" id="reason" name="reason" placeholder="Please key in the reasons." style="display:none">

</div>

<body>

</html>

关于javascript - html输入框消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49724054/

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