KentZhou
KentZhou

Reputation: 25553

How to get Checkbox status?

I have following html control in view:

  <%= Html.CheckBox("MyStatus", (item.MyStatus>0)?true:false)%>

Then I want to get the value for this checkbox: if it is checked, return true, otherwise return false. I try it as below:

$("#MyStatus").attr("checked").value

but I can't get the right value.

How to resolve it?

Upvotes: 2

Views: 355

Answers (2)

easement
easement

Reputation: 6139

How to check if checkbox is checked using jQuery http://jquery-howto.blogspot.com/2008/12/how-to-check-if-checkbox-is-checked.html

Upvotes: 0

Josh Stodola
Josh Stodola

Reputation: 82483

$("#MyStatus").is(":checked");

Upvotes: 4

Related Questions