我目前有这个代码&寻找展示的简单和更短的方式,隐藏&禁用我的元素更简单的方法...显示,隐藏和禁用元素
$("#chReportData").click(function() {
if ($(this)[0].checked) {
$("#reportDataOptions").show();
} else {
$("#ReportDataStatusOptions").hide();
$("#reportDataOptions").hide();
$('#chkReportPermission').attr('checked', false);
$('#chReportDataStatus').attr('checked', false);
$('#chReportDataCummulative').attr('checked', false);
$('.allowedUpload').attr('checked', false);
$('.allowedDelete').attr('checked', false);
}
});
$("#chReportDataStatus").click(function() {
if ($(this)[0].checked) {
$("#ReportDataStatusOptions").show();
} else if ($('#chReportDataCummulative').is('checked')) {
$("#ReportDataStatusOptions").hide();
$('.allowedUpload').attr('checked', false);
$('.allowedDelete').attr('checked', false);
} else {
$("#ReportDataStatusOptions").hide();
$('.allowedUpload').attr('checked', false);
$('.allowedDelete').attr('checked', false);
}
});
它正常工作,我“M只是寻找一个更简单的方法...如果你知道一个较短&更简单的方法,请分享...
张贴在http://codereview.stackexchange.com/ –
这个问题似乎是题外话因为它是关于代码优化 –
好吧...没问题...谢谢你让我知道! – Norris