Jquery .单击/处于选中状态:不在chrome上工作

Jquery .单击/处于选中状态:不在chrome上工作,jquery,google-chrome,Jquery,Google Chrome,我得到了这个函数打开一个div,我的复选框被选中了,但在chrome上不起作用,它在ie8/9、firefox、opera和safari上起作用。知道为什么吗 $('#checkbox-01').click(function () { if ($('#checkbox-01').is(':checked')) { $('.box').fadeIn('fast'); $('.square').hide('fast'); } else {

我得到了这个函数打开一个div,我的复选框被选中了,但在chrome上不起作用,它在ie8/9、firefox、opera和safari上起作用。知道为什么吗

$('#checkbox-01').click(function () {
    if ($('#checkbox-01').is(':checked')) {
        $('.box').fadeIn('fast');
        $('.square').hide('fast');
    } else {
        $('.box').fadeOut('fast');
        $('.square').hide('fast');
    }
});  
使用该功能:

$('#checkbox-01').change(function (){    
if(this.checked) {
    $('.box').fadeIn('fast');
    $('.square').hide('fast');
}else{
    $('.box').fadeOut('fast');
    $('.square').hide('fast');
}
});
使用此代码

$('#checkbox-01').click(function () {
if($(this).attr('checked') == 'checked'){
    $('.box').fadeIn('fast');
    $('.square').hide('fast');
} else {
    $('.box').fadeOut('fast');
    $('.square').hide('fast');
}
});

使用
this.checked
而不是
$('.#checkbox-01')。is(':checked')
代码在chrome中工作,请参见fiddlediddle:checked或not checked,
$('.square')
div始终隐藏,与您的代码相同。您可以将该代码放在click函数之外!它立即显示和显示…实际上“其他”同时触发,你知道吗?同一个人,东西显示和消失,我不明白为什么它只在chrome中发生