我有我的JQuery返回null问题。
这里是我的JQuery(其中包含在.js)....
$(document).ready(function() {
var chkBox = $("#gvEntryPoints input[id$='cbxIncludeAll']");
chkBox.click(function() {
$("#gvEntryPoints input[type='checkbox']").attr('checked', chkBox.is(':checked'));
});
// To deselect CheckAll when a GridView CheckBox is unchecked
$("#gvEntryPoints INPUT[type='checkbox']").click(function(e) {
if (!$(this)[0].checked) {
chkBox.attr("checked", false);
}
});
}
看样子chkBox从未被分配,因此从来就没有被分配一个click事件。
这是我的HTML ...
<asp:GridView CssClass="GridView" ID="gvEntryPoints" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:TemplateField Visible="false">
<ItemStyle CssClass="GridView_Item" />
<ItemTemplate>
<asp:Label runat="server" ID="lblEntryPointListItemId" Text='<%# Eval("EntryPointListItemId") %>'/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField Visible="false">
<ItemStyle CssClass="GridView_Item" />
<ItemTemplate>
<asp:Label runat="server" ID="lblEntryPointId" Text='<%# Eval("EntryPointId") %>'/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Include">
<ItemStyle CssClass="GridView_Item" />
<HeaderTemplate>
<asp:CheckBox runat="server" ID="cbxIncludeAll" CssClass="label" Checked="true" Text="Include<br/>All" TextAlign="Left" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox runat="server" ID="cbxEPInclude" name="EPInclude" CssClass="EPCheckBox" Checked="true" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
我的HTML位于.ascx中。 .ascx包含在.aspx内容页面上。我拥有包含在Master页面上的JQuery库(我已经在头部,身体顶部和身体底部尝试过)。
这是我见过的最奇怪的HTML *。 – nickf 2009-10-06 14:24:14
...也就是说,你可以发布一些*真正的* HTML?喜欢,页面的来源? – nickf 2009-10-06 14:25:45