Html 无线电输入不改变值?
我有一个收音机输入,当选择时,它不会改变值。它只是简单地说,Html 无线电输入不改变值?,html,twitter-bootstrap,Html,Twitter Bootstrap,我有一个收音机输入,当选择时,它不会改变值。它只是简单地说,Domain始终是值 <div class="col-xs-2"> <label class="radio-inline" for="AccountType_Domain"> <input id="AccountType_Domain" name="AccountType" type="radio" value="Domain">Domain</label>
Domain
始终是值
<div class="col-xs-2">
<label class="radio-inline" for="AccountType_Domain"> <input id="AccountType_Domain" name="AccountType" type="radio" value="Domain">Domain</label>
<label class="radio-inline" for="AccountType_Local"> <input id="AccountType_Local" name="AccountType" type="radio" value="Local">Local</label>
</div>
领域
地方的
起初我使用的是@html.RadioButtonFor
,但这导致两个输入具有相同的id
执行$(“输入:radio[AccountType]”.val()
时,无论选择了什么,我都只得到域 您需要使用:
$(“输入[name='AccountType']:选中”).val()
领域
地方的
您必须使用:选中的css选择器
因此,要在jQuery中获取所选AccountType项的值,它将如下所示:
$('input[name=AccountType]:checked').val()
您缺少:checked
选择器。