显示none不工作Laravel


Display none not working Laravel

我有一个条件,如果选中active,那么它将显示一个文本表单。

这是我的视图代码:

<div class="form-group">
  <label>Active:</label>
  {{ Form::checkbox('active', 0,null, array('id' =>'active_check','class' => 'active_check')) }}
</div>
<div id ="join_date" class="form-group" style="display: none;">
  <label>Join Date:</label>
  <div class="input-group">
    {!! Form::text('join_date', null, array('class' => 'form-control datetimepicker' )) !!}
  </div>
</div> 

这是目前为止我的jQuery切换和检查条件代码:

$('#active_check').click(function() {
    $("#join_date").toggle(this.checked);
    $('#join_date').find('input[type="text"], textarea').val('');
});
var activeCheck = $('checkbox[name="active_check"]');
function checkActive(select) {
    if (select.val() == 0) {
        $('#join_date').hide();
    } else {
        $('#join_date').show();
    }
}
checkActive(activeCheck);

问题是当它第一次加载join_date表单不隐藏。我需要切换复选框来隐藏它。任何想法?

试试这个简单的逻辑:

if($('#active_check').is(':not(":checked")')) {//test if active_check is not checked 
 $('#join_date').hide();//hide it
}
$('#active_check').click(function() {
    $("#join_date").toggle();//toggle it
});