0

我在单选按钮列表项中有一个嵌套的文本框这里是代码

<asp:RadioButtonList ID="OtherEducInNursing" runat="server" RepeatColumns="1" RepeatDirection="Vertical" RepeatLayout="Table">
            <asp:ListItem Value="1">Certificate<input id="OtherEdNsgCertName" type="text" MaxLength="25"/></asp:ListItem>
            <asp:ListItem Value="2">Baccalaureate</asp:ListItem>
            <asp:ListItem Value="3">Master</asp:ListItem>
            <asp:ListItem Value="4">Doctorate</asp:ListItem>
            <asp:ListItem Value="5">None of the above</asp:ListItem></asp:RadioButtonList>

它在 chrome 中都可以正常工作,但是在 Firefox 中,当我尝试单击文本框时,闪烁的光标失去焦点,我必须单击文本框几次才能使光标返回

我添加了一些这样的代码

 onclick="document.getElementById('OtherEdNsgCertName').focus();"

仍然没有工作,有谁知道为什么以及如何解决它?非常感谢

编辑这里也是jquery代码

$(document).ready(function () {
    if($("#<%=OtherEducInNursing.ClientID%> :checked").val()!="1")
            $("#OtherEdNsgCertName").hide();
        else
            $("#OtherEdNsgCertName").show();
    $("#<%=OtherEducInNursing.ClientID%>").click(function () {
        if($("#<%=OtherEducInNursing.ClientID%> :checked").val()!="1")
            $("#OtherEdNsgCertName").hide();
        else
            $("#OtherEdNsgCertName").show();
    });

编辑: html代码:

<table id="MainPlaceHolder_OtherEducation_OtherEducInNursing">
<tbody><tr>
    <td><input type="radio" value="1" name="ctl00$MainPlaceHolder$OtherEducation$OtherEducInNursing" id="MainPlaceHolder_OtherEducation_OtherEducInNursing_0"><label for="MainPlaceHolder_OtherEducation_OtherEducInNursing_0">Certificate<input type="text" onclick="document.getElementById('OtherEdNsgCertName').focus();" maxlength="25" id="OtherEdNsgCertName"></label></td>
</tr><tr>
    <td><input type="radio" value="2" name="ctl00$MainPlaceHolder$OtherEducation$OtherEducInNursing" id="MainPlaceHolder_OtherEducation_OtherEducInNursing_1"><label for="MainPlaceHolder_OtherEducation_OtherEducInNursing_1">Baccalaureate</label></td>
</tr><tr>
    <td><input type="radio" value="3" name="ctl00$MainPlaceHolder$OtherEducation$OtherEducInNursing" id="MainPlaceHolder_OtherEducation_OtherEducInNursing_2"><label for="MainPlaceHolder_OtherEducation_OtherEducInNursing_2">Master</label></td>
</tr><tr>
    <td><input type="radio" value="4" name="ctl00$MainPlaceHolder$OtherEducation$OtherEducInNursing" id="MainPlaceHolder_OtherEducation_OtherEducInNursing_3"><label for="MainPlaceHolder_OtherEducation_OtherEducInNursing_3">Doctorate</label></td>
</tr><tr>
    <td><input type="radio" value="5" name="ctl00$MainPlaceHolder$OtherEducation$OtherEducInNursing" id="MainPlaceHolder_OtherEducation_OtherEducInNursing_4"><label for="MainPlaceHolder_OtherEducation_OtherEducInNursing_4">None of the above</label></td>
</tr>

4

1 回答 1

0

从文本框中删除焦点功能并在您的 jQuery 中提供焦点:

$(document).ready(function () {
    if($("#<%=OtherEducInNursing.ClientID%> :checked").val()!="1")
        $("#OtherEdNsgCertName").hide();
    else
        {
            $("#OtherEdNsgCertName").show();
            $("#OtherEdNsgCertName").focus();
        }
$("#<%=OtherEducInNursing.ClientID%>").click(function () {
    if($("#<%=OtherEducInNursing.ClientID%> :checked").val()!="1")
        $("#OtherEdNsgCertName").hide();
    else
        {
            $("#OtherEdNsgCertName").show();
            $("#OtherEdNsgCertName").focus();
        }

});
于 2013-04-22T14:18:18.633 回答