我试图在选中其中一个复选框时隐藏一组复选框,并在未选中时让它们重新出现。条件必须基于它们的值。
var input = document.getElementsByTagName("input");
for(i=0;i<input.length;i++){
input[i].onchange = function(){
if(this.checked){
var value = $(this).val();
$("input[type=checkbox]:not(." + '60' + ")").hide();
$("input[type=checkbox]." + '60').show();
}
}
}
要隐藏的复选框组属于值 60 和 90(不能选择两个武器配件),想法是不能选择两个复选框,只有一个,所以这就是为什么我需要隐藏其中一个' 被选中,并让它们在未选中后重新出现。
<input type="checkbox" value="50" /> conductive plastic foot cup $50<br/>
<input type="checkbox" value="60" /> <a>T-arms 2 $60</a><br/>
<input type="checkbox" value="90" /> <a>T-arms 1 $90</a><br/>
<input type="checkbox" value="80" /> metal rails $80<br/>
<input type="checkbox" value="30" /> plastic rails $30<br/>
<input type="checkbox" value="70" /> foot rest ring $70<br/>
<input type="checkbox" value="120" />plastic five star foot $120 <br/>
这是我的小提琴:JS fiddle