4

我在以下代码中有一个单选按钮列表,如下所示update panel

<asp:RadioButtonList ID="RadioButtonList1" runat="server" Width="233px" 
                ClientIDMode="Static" AutoPostBack="true" 
                onselectedindexchanged="RadioButtonList1_SelectedIndexChanged">
                <asp:ListItem Value="1">1</asp:ListItem>
                <asp:ListItem Value="2">2</asp:ListItem>
                <asp:ListItem Value="3">3</asp:ListItem>
                <asp:ListItem Value="4">4</asp:ListItem>
            </asp:RadioButtonList>

我希望当用户单击此单选按钮的任何项目时Please Wait...显示文本而不是单选按钮文本。我编写以下代码:

function pageLoad() {
        $(document).ready(function () {
            $('#RadioButtonList1').on("change", function () {
                $("#RadioButtonList1 input:checked").val("Please Wait...");
            });
       });
    }

但它不起作用。我的错误在哪里?

谢谢

4

4 回答 4

1

您应该更改此代码:

$("#RadioButtonList1 input:checked").val("Please Wait...");

to

$("#RadioButtonList1 input:checked").parent().find('label').text("Please Wait");
于 2012-04-24T12:46:15.727 回答
1

radio按钮值不会显示在浏览器视口上,您应该使用labels 并更改其文本:

   $(document).ready(function () {
            $('#RadioButtonList1').on("change", function () {
                $("#RadioButtonList1 input:checked").closest("label").text("Please Wait...");
            });
       });
于 2012-04-24T12:50:42.973 回答
0

省略函数调用,只需在您的 javascript 代码块中使用它:

$(document).ready(function () {
    $('#RadioButtonList1').on("change", function () {
        $("#RadioButtonList1 input:checked").val("Please Wait...");
    });

});

于 2012-04-24T12:45:56.643 回答
0

尝试:

function pageLoad() {
        $(document).ready(function () {
            $('#<%=RadioButtonList1.ClientID %>').on("change", function () {
               $("#<%=RadioButtonList1.ClientID %>").find("input[checked]").val("Please Wait...");
            });
       });
    }
于 2012-04-24T12:49:47.713 回答