jQuery - ASP .NET RadioButtonList 控件 'Change' 事件从未触发



我有一个RadioButtonList控件,声明如下:

        <asp:RadioButtonList ID="rbtnlistUnits" runat="server"
            RepeatDirection="Horizontal" RepeatLayout="Table">
            <asp:ListItem Text="Metres"  Value="M"></asp:ListItem>
            <asp:ListItem Text="Feet" Value="Ft"></asp:ListItem>
        </asp:RadioButtonList>

我希望能够让选择影响屏幕上的功能,但选择任一按钮时不会触发change事件。

我最初没有在jQuery选择中包含input标签,并且刚刚在线阅读这可能是问题所在。它已被添加,但未更改。我对ASP .Net中的jQuery不是很熟悉,所以我想知道该语言的ListItem控件是否是与input略有不同的别名。

        $('#cSearch #rbtnlistUnits input').change(function() {
            console.info("changed"); //doesn't appear in console
        });

如果不是这种情况,有人能发现其他可能遗漏的东西吗?

谢谢马克

试试这个

 <asp:RadioButtonList ClientIDMode="Static" ID="rbtnlistUnits" runat="server"
                RepeatDirection="Horizontal" RepeatLayout="Table">
                <asp:ListItem Text="Metres"  Value="M"></asp:ListItem>
                <asp:ListItem Text="Feet" Value="Ft"></asp:ListItem>
            </asp:RadioButtonList>
    <script>
    $(function() {   
       $('#rbtnlistUnits').change(function() {
       console.info("changed"); 
       });
       });
</script>

最新更新