简体   繁体   中英

Get checkbox value in a variable in Ajax

I am trying to retrieve a checkbox value (If its checked or not) in AJAX in vb.net). But cannot seem to get the value. I am using the following method.

var myCheckBoxValue= $('#<%=myCheckBox.ClientID %>').val();

"myCheckBox" is the name of my checkbox Any help will be appreciated. Thanks

that's wrong. To get if a checkbox is checked or not you should do like this:

 $('#<%=myCheckBox.ClientID %>').prop( "checked" )

Reference: jQuery Doc

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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