简体   繁体   中英

How to have the value of the selected in radioButtonList

<html>
<asp:RadioButtonList runat="server" CssClass="status_Veh">
        <asp:ListItem ID="RadioButton1" runat="server" name="status"   Selected="True" Value="New">New</asp:ListItem>
        <asp:ListItem ID="RadioButton2" runat="server" name="status"    Value="Used" >Used</asp:ListItem>
    </asp:RadioButtonList>
</html>

need to have the selected value of the radio buttonList using Jquery

I'm using

var statusVeh = $(".status_Veh option:selected ").val();

it isn't working

nor is

var statusVeh = $(".status_Veh:checked").val();

Try $(".status_Veh input:checked").val();

RadioButtonList generates , so the option:selected selector won't work.

$(".status_Veh:checked").val() is not working, because you have to look the .status_Veh elements children for checked values. So $(".status_Veh :checked").val() should also work (notice the space in the selector).

你可以尝试$('input[name=status]:checked').val()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM