响应asp:RadioButtonList随jquery而变化

时间:2011-12-22 22:46:07

标签: c# jquery asp.net

我有下面的代码,在页面加载和用户选择单选按钮时将焦点设置在文本框上。

如何更改此选项,以便他们选择最后一个收音机选项" Mail"重点不是设定 txtPayerName但是改为btnSubmit控件?

 $(function () {
                    SetDefaultPaymentType();
                    $("#txtPayerName").focus();


                $("#rdLstPaymentOptions").change(function () {
                    $("#txtPayerName").focus();
                });

            });


<asp:RadioButtonList ID="rdLstPaymentOptions" runat="server" RepeatColumns="3" RepeatDirection="vertical"
                    RepeatLayout="Flow" OnPreRender="rdBtnLst_PreRender" TabIndex="1" 
                    ClientIDMode="Static">
                    <asp:ListItem Text="Credit Card&nbsp;&nbsp;&nbsp;" Value="CreditCard" ></asp:ListItem>
                    <asp:ListItem Text="Electronics Fund Transfer&nbsp;&nbsp;&nbsp;" Value="EFT"></asp:ListItem>
                    <asp:ListItem Text="Check By Mail&nbsp;&nbsp;&nbsp;" Value="Mail"></asp:ListItem>
                </asp:RadioButtonList>

2 个答案:

答案 0 :(得分:1)

如果您分别在每个单选按钮上设置更改事件,该怎么办?

类似的东西:

$("#rdLstPaymentOptions").each(function (index) {  
   if (index == $("#rdLstPaymentOptions").length - 1) {
      // insert code to set change event for last radio button
   }
   else {
      ($this).change = function () {
         $("#txtPayerName").focus(); 
      }
   }
}); 

答案 1 :(得分:0)

给单选按钮和提交按钮一个唯一的CSS类,然后使用:

$('.radioClass').click(function() {
    $('.submitClass').focus()
})
相关问题