我有问题,这项工作和一切正常,但复选框不太好 如果我标记checkbox1
后重新加载它的标记checkbox2
和checkbox1
。我必须帮助找到这个工作。jQuery复选框隐藏并显示div
只保存复选框标记
$(function(){
$('#checkbox1')
.prop('checked', localStorage.input === 'true')
.on('change', function() {
localStorage.input = this.checked;
if (this.checked) {
$('.column_category').show(0); //checked
} else {
$('.column_category').hide(0);
}
})
.trigger('change');
});
$(function(){
$('#checkbox2')
.prop('checked', localStorage.input === 'true')
.on('change', function() {
localStorage.input = this.checked;
if (this.checked) {
$('.column_sku').show(0); //checked
} else {
$('.column_sku').hide(0);
}
})
.trigger('change');
});
<input type="checkbox" id="checkbox1"/><label for="cbxShowHide">Categories</label>
<input type="checkbox" id="checkbox2"/><label for="cbxShowHide">SKU</label>
<input type="checkbox" id="checkbox3"/><label for="cbxShowHide">UPC</label>
没有问题,但你并不需要一个0中显示或隐藏方法 – clearshot66