2013-12-09 55 views
-1

HTML:EditorFor复选框始终返回false

<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); 

Howcome我总是即使复选框被选中假的。

this doesnt help

neither does this

回答

1

因为#IsFeatured是一个div并不是一个复选框尝试

var IsFeatured = $('#IsFeatured input[type="checkbox"]').is(':checked');