我仅在 Firefox 上使用 jQuery 代码时遇到问题,该代码在选中某个框时显示 html 详细信息,而该框在取消选中时应该会再次消失。代码是:
$('#gepaeck').on('click', function() {
showGepaeckwert($(this));
});
function showGepaeckwert(t) {
status = $(t).prop('checked');
if (status) {
$('.Gepaeck').show();
} else {
$('.Gepaeck').hide();
}
}
在 Chrome 上它运行良好。在这种情况下有人可以给我提示或帮助吗?
谢谢!
最佳答案
如果#gepaeck
是一个复选框(输入),那么:
$('#gepaeck').on('change', showGepaeckwert);
function showGepaeckwert(e) {
$('.Gepaeck').toggle( this.checked );
}
<小时/>
jQuery toggle()方法文档:
The second version of the method accepts a Boolean parameter. If this parameter is true, then the matched elements are shown; if false, the elements are hidden.
关于javascript - 取消选中后 jQuery 不会隐藏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44696101/