HTML
<div>Group 1
<br>
<input type="checkbox" name="testing" value="B"> <label>A<span>(34)</span></label>
<br />
<input type="checkbox" name="testing" value="I"> <label>B<span>(0)</span></label>
<br />
<input type="checkbox" name="testing" value="A"> <label>C<span>(323)</span></label>
<br />
</div>
<div>Group 2
<br>
<input type="checkbox" name="testing2" value="B"><label>A<span>(0)</span></label>
<br />
<input type="checkbox" name="testing2" value="I"><label>B<span>(564)</span></label>
<br />
<input type="checkbox" name="testing2" value="A"> <label>C<span>(0)</span></label>
<br />
</div>
JS
$("input:checkbox").change(function () {
var checkname = $(this).attr("name");
if (this.checked) {
$("input:checkbox[name='" + checkname + "']").removeAttr("checked").parent().hide();
this.checked = true;
$(this).parent().show();
} else {
$("input:checkbox[name='" + checkname + "']").parent().show();
}
if($(".options input:checkbox + label span:contains('(0)')")){
$(this).parent().hide();;
}else{
$(this).parent().show();
}
});
$("input:checkbox[checked]").trigger("change");
如果子跨度包含(0),我想隐藏带有标签的复选框。你可以看到我在上面尝试过的,但它不起作用。怎么做 ?