我有一个Webform应用程序,在.aspx页面中,我有多个表,每个表都有复选框列表。
我想在文本框键入事件中获得预订人员复选框,但它会在每个表中搜索所有复选框列表
这是预订人员复选框的代码
<table cellpadding="0" cellspacing="0" class="tblEntry" id="tblPersonnel">
<tr>
<td class="tableheading">BOOKING PERSONNEL DETAILS
</td>
</tr>
<tr>
<td class="tblEntryOneColumn" style="display: block; overflow-y: scroll; height: 285px; border-bottom: 1px solid #DDD;">
<asp:TextBox ID="txtSearch" runat="server"></asp:TextBox>
<asp:CheckBoxList ID="cblBookingBy" runat="server" />
</td>
</tr>
</table>
及以下是项目详细信息复选框列表
<table cellpadding="0" cellspacing="0" class="tblEntry">
<tr>
<td class="tableheading">PROJECTS DETAILS
</td>
</tr>
<tr>
<td id="tdProjects" runat="server" class="tblEntryOneColumn" style="display: block; overflow-y: scroll; height: 300px; border-bottom: 1px solid #DDD;">
<asp:CheckBoxList ID="cblProjects" runat="server" ValidationGroup="projects" />
<asp:CustomValidator ID="CustomValidator" runat="server" ErrorMessage="Please select at least one project!"
ClientValidationFunction="ValidateProjectList" CssClass="ValidationError" Style="margin-top: -355px;"
ValidationGroup="projects">Please select at least one project</asp:CustomValidator>
</td>
</tr>
</table>
问题在于下面的jquery代码,它只在两个表中搜索,我只希望它仅搜索预订人员表复选框列表
$('#<%= txtSearch.ClientID %>').bind('keyup', function (event) {
var valThis = $(this).val().toLowerCase();
$('input[type=checkbox]').each(function () {
var text = $("label[for='" + $(this).attr('id') + "']").text().toLowerCase();
(text.indexOf(valThis) == 0) ? $(this).parent().show() : $(this).parent().hide();
});
});