0

当初始化我的表单时,它看起来像这样:

                <?php if ($row['active'] == 1) { ?>
        <td><input type="checkbox" name="active[]" checked="checked" value="1"></td>
    <?php } else { ?>
        <td><input type="checkbox" name="active[]" value="0"></td>
    <?php } ?> 

我要抓住所有活动的 jQuery 是:

'active': $("input[name='active\\[\\]']").map(function(){return $(this).val();}).get()

但是,这并没有给我我需要的价值。如果未选中,我需要值 0,如果选中,则需要值 1,存储在上面 jQuery 中的数组中。但我的支票无法改变这一点。

解决方案:'active': $("input[name='active\\[\\]']").map(function(){return $(this).is(':checked');}).get()

4

0 回答 0