【问题标题】:EditorFor checkbox always returning falseEditorFor 复选框总是返回 false
【发布时间】:2013-12-09 23:06:45
【问题描述】:

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

为什么即使选中了复选框,我也总是出错。

this doesnt help

neither does this

【问题讨论】:

    标签: jquery checkbox


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2021-08-24
      • 2019-03-13
      • 2020-06-16
      • 2012-02-16
      • 1970-01-01
      • 2014-10-13
      • 1970-01-01
      相关资源
      最近更新 更多