gpt4 book ai didi

jquery - 如果使用 jQuery 检查单选按钮则显示框

转载 作者:行者123 更新时间:2023-11-30 23:48:02 24 4
gpt4 key购买 nike

我有以下代码:

    <fieldset>
<legend>Do you currently have SolidWorks</legend>

<ul>
<li><label for=""><input type="radio" name="solidworks" value="Yes" id="rdYes" /> Yes</label></li>
<li><label for=""><input type="radio" name="solidworks" value="No" id="rdNo" /> No</label></li>
</ul>
</fieldset>

<fieldset id="boxReseller" style="display:none;">
<legend>Who is your SolidWorks reseller?</legend>
<ul>
<li><label for=""><input type="radio" name="reseller" value="Cad Connect" /> Cad Connect</label></li>
<li><label for=""><input type="radio" name="reseller" value="Cadtek" /> Cadtek</label></li>
<li><label for=""><input type="radio" name="reseller" value="CCSL" /> CCSL</label></li>
<li><label for=""><input type="radio" name="reseller" value="Innova" /> Innova</label></li>
<li><label for=""><input type="radio" name="reseller" value="NT CAD/CAM" /> NT CAD/CAM</label></li>
<li><label for=""><input type="radio" name="reseller" value="Solid Engineer" /> Solid Engineer</label></li>
<li><label for=""><input type="radio" name="reseller" value="Solid Solutions Ireland" /> Solid Solutions Ireland</label></li>
<li><label for=""><input type="radio" name="reseller" value="Solid Solutions Management" /> Solid Solutions Management</label></li>
<li><label for=""><input type="radio" name="reseller" value="TMS Scotland" /> TMS Scotland</label></li>
</ul>

</fieldset>

我想要做的是默认隐藏第二个字段集,如果一个人选择"is",则该框将出现,如果他们选择“否”或未选择"is",则该框将再次隐藏。

有人可以帮忙吗?谢谢。

最佳答案

你可以这样做:

$("input[name='solidworks']").change(function() {
$("#boxReseller").toggle(this.value == "Yes");
});​​​​​​
$("input[name='solidworks']:checked").change(); //trigger correct state onload

You can give it a try with the markup in the question here ,然后尝试 pre-checked "Yes" version here .

关于jquery - 如果使用 jQuery 检查单选按钮则显示框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3791038/

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