0

There is a checkbox created by html helper in MVC view:

<%= Html.CheckBox("Choice", false)%>

Then Want to get the checking status of this this checkbox in js using jquery, how to write the code?

1 Answer 1

1
if($('#Choice').is(':checked')) {
  //is checked
} else {
  //is not checked
}

or you might even be able to do

if($('#Choice:checked')) {
  //is checked
} else {
  //is not checked
}
Sign up to request clarification or add additional context in comments.

1 Comment

Ouch!I've been bitten by this. The value seems to be either true for checked, or "undefined" for false. OK for simple logic as above, but I had a smidgen more logic to process, with the expectation I'd get a false.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.