KentZhou
KentZhou

Reputation: 25583

how to get checkbox status in from MVC view using jquery

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?

Upvotes: 0

Views: 4015

Answers (1)

Colin
Colin

Reputation: 2502

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
}

Upvotes: 1

Related Questions