Firefox和谷歌浏览器中的Jquery问题?

时间:2014-03-14 19:01:53

标签: javascript jquery html google-chrome firefox

我有一个jquery,用于.net网页中不同控件的必需验证。 j查询在IE中工作正常,但在谷歌浏览器和Firefox中它不起作用。

在这个j查询中,我正在检查当前控件是否已启用,然后我检查内部输入是否已启用。如果它们都被启用,那么我检查是否,如果未选择至少一个输入,则我存储该值,然后警告它。 这个查询在IE中运行良好,但在Firefox和谷歌Chrome中它甚至都没有检查它。

 if ($("#<%=chk_ctrl.ClientID%>").is(':enabled')) {
        if ($("#<%=chk_ctrl.ClientID%> input[type='radio']").is(':enabled')) {
          if ($("#<%=chk_ctrl.ClientID%> input[type='radio']:checked").length == 0) {
                      names.push($("#<%=chk_ctrl.ClientID%> input[type='radio']").parent().closest("table").parent().children("h3").text()); +"\n";
                    }
                } 
            }

所以这适用于IE它在Chrome和FireFox中不起作用......任何想法

这是HTML

我不确定是否需要HTML但是只是在案例中。这是一个asp.net checkboxlist服务器控件

<table id="ctl00_m_g_c09fd465_0ae4_479b_8fc6_21a7de645003_ctl00_chk_ctrl" class="required" border="0">
    <tr>
        <td><input id="ctl00_m_g_c09fd465_0ae4_479b_8fc6_21a7de645003_ctl00_chk_ctrl_0" type="checkbox" name="ctl00$m$g_c09fd465_0ae4_479b_8fc6_21a7de645003$ctl00$chk_ctrl$0" /><label for="ctl00_m_g_c09fd465_0ae4_479b_8fc6_21a7de645003_ctl00_chk_ctrl_0">Short-term exposure</label></td>
    </tr><tr>
        <td><input id="ctl00_m_g_c09fd465_0ae4_479b_8fc6_21a7de645003_ctl00_chk_ctrl_1" type="checkbox" name="ctl00$m$g_c09fd465_0ae4_479b_8fc6_21a7de645003$ctl00$chk_ctrl$1" /><label for="ctl00_m_g_c09fd465_0ae4_479b_8fc6_21a7de645003_ctl00_chk_ctrl_1">Medium-term exposure</label></td>
    </tr><tr>
        <td><input id="ctl00_m_g_c09fd465_0ae4_479b_8fc6_21a7de645003_ctl00_chk_ctrl_2" type="checkbox" name="ctl00$m$g_c09fd465_0ae4_479b_8fc6_21a7de645003$ctl00$chk_ctrl$2" /><label for="ctl00_m_g_c09fd465_0ae4_479b_8fc6_21a7de645003_ctl00_chk_ctrl_2">Long-term exposure</label></td>
    </tr>
</table>

1 个答案:

答案 0 :(得分:0)

正确的方式而不是使用是使用道具和检查禁用。

     if (!($("#<%=lstExposureValue.ClientID%>").prop('disabled')))