我在我的页面上有一个具有多个选项的RadioButtonList控件。我想处理其选项的更改,并且根据所选选项的值,可以正常工作。
这不起作用:
$(document).ready(function () {
$('#RadioButtonList1').change(function () {
if ($(this).is(':checked')) {
alert("yes");
}
});
});
我如何处理?
感谢
答案 0 :(得分:17)
你只需要绑定输入本身,而不是它们的组:
$(document).ready(function () {
$('#RadioButtonList1 input').change(function () {
// The one that fires the event is always the
// checked one; you don't need to test for this
alert($(this).val());
});
});
答案 1 :(得分:1)
可能这个可以帮助你:)
$('form#package_information_id').on('change','.shipment_type_radio_class',function(){
var currentselval = $(this).find('input[type="radio"]:checked');
//console.log(currentselval);
if(currentselval.val()=='dropoff')
{
$('.pickup_detail_class').hide();
}else
{
$('.pickup_detail_class').show();
}
});
答案 2 :(得分:0)
enter code here
<div>
<asp:RadioButtonList ID="rblTest" runat="server">
<asp:ListItem>10</asp:ListItem>
<asp:ListItem>20</asp:ListItem>
<asp:ListItem>30</asp:ListItem>
<asp:ListItem>40</asp:ListItem>``
</asp:RadioButtonList>
</div>
<script type="text/javascript">
$(function() {
var val = "";
val = $('[id*=rblTest]').find('input:checked').val();
if (val != "" && val != undefined) {
alert("Selected item value is : " + val)
}
});
</script>