gpt4 book ai didi

javascript - 禁用 Jquery 中单选列表控件中的单选按钮

转载 作者:行者123 更新时间:2023-12-01 04:07:53 25 4
gpt4 key购买 nike

我必须根据条件禁用给定单选列表控件中的单选按钮。问题是单选按钮列表是由 CMS 自动生成的,并且所有列表项的 id 都相同。我如何根据条件应用“禁用”类。例如 if (some value == am) 然后显示第一个单选按钮并禁用其他两个。

<div class="fieldset">       
<div class="radio">
<label >
<input id="wffmd4800a78bba44322993e9ef2a91e0ea0_Sections_9__Fields_3__Value" name="wffmd4800a78bba44322993e9ef2a91e0ea0.Sections[9].Fields[3].Value" type="radio" value="Morning (8 AM - 1 PM)">
<span class="disable">Morning (8 AM - 1 PM)</span>
</label>
</div>
<div class="radio">
<label>
<input id="wffmd4800a78bba44322993e9ef2a91e0ea0_Sections_9__Fields_3__Value" name="wffmd4800a78bba44322993e9ef2a91e0ea0.Sections[9].Fields[3].Value" type="radio" value=" Afternoon (1 PM - 5 PM)" aria-invalid="false">
<span> Afternoon (1 PM - 5 PM)</span>
</label>
</div>
<div class="radio">
<label>
<input id="wffmd4800a78bba44322993e9ef2a91e0ea0_Sections_9__Fields_3__Value" name="wffmd4800a78bba44322993e9ef2a91e0ea0.Sections[9].Fields[3].Value" type="radio" value=" Evening (5 PM - 9 PM)">
<span> Evening (5 PM - 9 PM)</span>
</label>
</div>
</div>
</div>

最佳答案

这不是一个好主意,但是您可以使用 jquery 通过 value 属性的值选择 radio 并禁用相关 radio (使用 prop 方法) :

$('input[type="radio"][value=" Afternoon (1 PM - 5 PM)"]').prop('disabled', true);
$('input[type="radio"][value=" Evening (5 PM - 9 PM)"]').prop('disabled', true);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="fieldset">
<div class="radio">
<label >
<input id="wffmd4800a78bba44322993e9ef2a91e0ea0_Sections_9__Fields_3__Value" name="wffmd4800a78bba44322993e9ef2a91e0ea0.Sections[9].Fields[3].Value" type="radio" value="Morning (8 AM - 1 PM)">
<span class="disable">Morning (8 AM - 1 PM)</span>
</label>
</div>
<div class="radio">
<label>
<input id="wffmd4800a78bba44322993e9ef2a91e0ea0_Sections_9__Fields_3__Value" name="wffmd4800a78bba44322993e9ef2a91e0ea0.Sections[9].Fields[3].Value" type="radio" value=" Afternoon (1 PM - 5 PM)" aria-invalid="false">
<span> Afternoon (1 PM - 5 PM)</span>
</label>
</div>
<div class="radio">
<label>
<input id="wffmd4800a78bba44322993e9ef2a91e0ea0_Sections_9__Fields_3__Value" name="wffmd4800a78bba44322993e9ef2a91e0ea0.Sections[9].Fields[3].Value" type="radio" value=" Evening (5 PM - 9 PM)">
<span> Evening (5 PM - 9 PM)</span>
</label>
</div>
</div>

关于javascript - 禁用 Jquery 中单选列表控件中的单选按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41676367/

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