Firefox失去了对嵌套文本框的关注

时间:2013-04-22 13:34:42

标签: asp.net html

我在radiobuttom列表项中有一个嵌套文本框 这是代码

<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>

1 个答案:

答案 0 :(得分: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();
        }

});