【问题标题】:How to get value from RadioButtonList using jQuery?如何使用 jQuery 从 RadioButtonList 中获取值?
【发布时间】:2013-12-26 21:48:12
【问题描述】:
我需要找出 RadioButtonList 的选定值是什么:
<div class="editor-field radio-button-list">
<%= Html.RadioButtonListForEnum("Type", Model.Type)%>
</div>
我尝试使用:$("#Type").find(":checked").val(),但我得到的只是“未定义”......有什么想法吗?
【问题讨论】:
标签:
jquery
radiobuttonlist
【解决方案1】:
var val = $('#<%= ControlID.ClientID %> input:checked').val();
【解决方案2】:
它适用于服务器端控制:
$("#<%=ControlID.ClientID%>").find(":checked").val();
【解决方案3】:
$(".editor-field.radio-button-list:checked").val()
【解决方案4】:
我不确定 Type 的 id 是否如您所想。或者 Type 可能是一个重复的 Id。无论如何,我认为这就是你想要的
$(".editor-field.radio-button-list").find(":checked").val()