JS入门选手 求大神帮忙看看这段JS怎么简化
$(document).ready(function(){
$(".planwrapper .zx #checkbox_c1").click(function(){
if($(this).is(':checked')){
$(".tbr").fadeIn();
$(this).parent().prev().find("input").attr("checked",true);
}
else if($(this).not(':checked')){
$(".tbr").fadeOut();
$(this).parent().prev().find("input").attr("checked",false);
}
});
$(".planwrapper .zx #checkbox_c2").click(function(){
if($(this).is(':checked')){
$(".bbr").fadeIn();
$(this).parent().prev().find("input").attr("checked",true);
}
else if($(this).not(':checked')){
$(".bbr").fadeOut();
$(this).parent().prev().find("input").attr("checked",false);
}
});
});
这就是一个点击隐藏显示的代码 有两个按钮 点第一个显示/隐藏第一个的DIV 点第二个显示/隐藏第二个的DIV
我知道还有更好的办法写这种效果 但是我就是问上面这段代码怎么改能简化