我在 ASP.NET webforms 中使用这个 jquery 代码来检查复选框的值,然后打开或关闭 div。这没用...
$(document).ready(function ()
{
$('#checkboxOperator2').click(function ()
{
if ($(this).is(':checked'))
{
$('#showOperator2').show();
}
else
{
$('#showOperator2').hide();
}
alert("Click");
});
});
我像这样引用jquery:
<asp:ScriptManager id="sm1" runat="server">
<Scripts>
<asp:ScriptReference Path="~/Scripts/jquery-2.0.3.js" />
</Scripts>
</asp:ScriptManager>
我的代码不正确吗?我没有收到任何错误。
这是我的标记:
<asp:CheckBox ID="checkboxOperator2" Checked='<%# Bind("SecondaryOperator") %>' runat="server" Style="position:absolute; top: 161px; left: 650px;" />
<div id="showOperator2" style="visibility:hidden";>
<asp:Label ID="Label4" runat="server" Text="Secondary Operator" Style="position:absolute; top: 161px; left: 500px; width: 200px;"></asp:Label>
<asp:DropDownList ID="dropdownOperator2" runat="server" Style="position:absolute; top: 161px; left:650px; width: 200px;"
Text='<%# Bind("SecondaryOperatorID") %>' AppendDataboundItems="true" DataSourceID="OperatorDS" DataTextField="OperatorName" DataValueField="ID" >
<asp:ListItem text="None" Value="" />
</asp:DropDownList>
</div>