【发布时间】:2013-12-05 06:11:13
【问题描述】:
我有一个仅在选中“其他”选项时显示的输入字段。当我取消选中“其他”复选框时,输入字段会淡出,但我也希望输入字段淡出,而不是取消选中“其他”复选框,而是选中同一组的另一个复选框。因此,除非选中“其他”,否则“其他”输入字段不应可见。我的 javascript 部分工作,但是当我选中另一个复选框时,“其他”输入字段仍然可见。
HTML
<input type="checkbox" id="residence_check" name="found"/>
<label for="residence_check">
Residence
</label>
<input type="checkbox" id="tradeshow_check" name="found"/>
<label for="tradeshow_check">
Tradeshow
</label>
<input type="checkbox" id="office_check" name="found"/>
<label for="office_check">
Office Building
</label>
<input type="checkbox" id="check_other" value="found_other" name="found"/>
<label for="check_other">
Other
</label>
<input type="text" id="check_input" placeholder="Other"/>
Javascript
$('#check_other').change(function() {
if($(this).is(":checked")) {
$('#check_input').fadeIn();
} else {
$('#check_input').fadeOut('fast');
}
});
【问题讨论】:
标签: javascript jquery checkbox hide unchecked