【发布时间】:2016-04-04 09:40:52
【问题描述】:
我想在选中第一个单选按钮时启用文本框,如果第二个则我想禁用文本框这是我的代码不起作用请帮助..
<label class="radio-inline">
<input type="radio" value="Y" name="IsLive" class="grey">
YES
</label>
<label class="radio-inline">
<input type="radio" value="N" name="IsLive" class="grey">
NO
</label>
<label class="col-sm-2 control-label">
Live Date
</label>
<div class="col-sm-3">
<input type="text" id="LiveDate" name="LiveDate" class="form-control date-picker">
</div>
$('input:radio[name="IsLive"]').change(function () {
if ($(this).is(':checked') && $(this).val() == 'Y') {
// append goes here
$("#LiveDate").show();
} else {
$("#LiveDate").prop("disabled", true);
}
});
【问题讨论】:
-
使用 $('input:radio[name="IsLive"]') 代替 $('.grey') 进行选择
标签: javascript jquery