HTML:
<div class="editor-label">
<%: Html.LabelFor(model => model.IsFeatured)%>
</div>
<div id="IsFeatured" class="editor-field textbox">
<%: Html.EditorFor(model => model.IsFeatured)%>
<%: Html.ValidationMessageFor(model => model.IsFeatured)%>
jQuery的:
var IsFeatured = $('#IsFeatured').is(':checked');
alert('IsFeatured= '+IsFeatured);
如果选中复选框,我总是会弄错。
答案 0 :(得分:1)
因为#IsFeatured
是div而不是复选框,请尝试
var IsFeatured = $('#IsFeatured input[type="checkbox"]').is(':checked');