[英]Check / Uncheck ASP CheckBox with JQuery
如何使用JQuery选中/取消选中以下ASP复选框?
<asp:CheckBox ID="cbImg1" CssClass="cbImg1" Checked="true" Visible="false" ClientIDMode="Static" runat="server" Width="130px" ForeColor="#909090" Font-Size="12px" />
Your code :- 您的代码:-
<asp:CheckBox ID="cbImg1" CssClass="cbImg1" Checked="true" Visible="false" ClientIDMode="Static" runat="server" Width="130px" ForeColor="#909090" Font-Size="12px" />
in jQuery you can try prop() :- 在jQuery中,您可以尝试prop() :-
$("#cbImg1").prop('checked', true); //// To check
$("#cbImg1").prop('checked', false); //// To un check
First change your 首先改变你的
<asp:CheckBox ID="cbImg1" CssClass="cbImg1" Checked="true" Visible="false" ClientIDMode="Static" runat="server" Width="130px" ForeColor="#909090" Font-Size="12px" />
to 至
<asp:CheckBox ID="cbImg1" CssClass="cbImg1" Checked="true" style="display:none" ClientIDMode="Static" runat="server" Width="130px" ForeColor="#909090" Font-Size="12px" />
remove Visible="false" and make it to display none. 删除Visible =“ false”并使其不显示。
Then let's say you have button, add the following script to it. 然后,假设您有一个按钮,向其中添加以下脚本。
OnClientClick="buttonClick(); return false;
And add the javascript like... 并像这样添加JavaScript ...
<script type="text/javascript">
function buttonClick() {
$("#<%=cbImg1.ClientID %>").prop('checked', true);
alert('Called');
}
</script>
See if the alert appears or not... 查看警报是否出现...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.