简体   繁体   English

通过jquery获取asp.net CheckBox的值(true / false)

[英]Get value of asp.net CheckBox via jquery(true/false)

got the answer syntax error 得到了答案语法错误

i want to get value of asp.net check box via jquery , if its selected return true otherwise false. 我想通过jquery获取asp.net复选框的值,如果它的选择返回true,否则为false。 i'm doing this: - 我这样做: -

  var ApprovalRequired = $('<%= chkRequired.ClientID %>').is(':checked');
  // also
   var ApprovalRequired = $('<%= chkRequired.ClientID %>').val();

and the checkbox return in html as 并且复选框在html中返回为

  <input id="ctl00_ContentPlaceHolder1_chkRequired" type="checkbox" name="ctl00$ContentPlaceHolder1$chkRequired" checked="checked">

in either way its returning 'false'. 以任何一种方式返回'假'。 Any idea to get true when checked and false on unchecked 任何想法在检查时变为真,在未经检查时变为假

You forgot the # in your selector: 你忘记了选择器中的#

$('#<%= chkRequired.ClientID %>').is(':checked');

That should work 这应该工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM