2013-12-09 84 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');