我在我的表单中使用了两个单选按钮,然后按照这两个单选按钮我有另一个字段。 如果只选中某个单选按钮,我想显示该字段。否则默认情况下它应该被隐藏。
我的代码
支付方式
<div class="list"> <label class="item item-radio"> <input type="radio" name="group"> <div class="item-content"> Immediate Payment </div> <i class="radio-icon ion-checkmark"></i> </label> <label class="item item-radio"> <input type="radio" name="group"> <div class="item-content"> Scheduled Payment </div> <i class="radio-icon ion-checkmark"></i> </label> </div> <label><h4><b>Effective Date*</b></h4></label> <input type="date" >
这里我只想在用户选中“预定付款”单选按钮时显示生效日期字段。我该怎么做?
最佳答案
$("input[name=group]").change(function () {
if ($(this).val() == 'scheduled' && $(this).is(":checked")) {
$("#effectiveWrapper").show();
} else {
$("#effectiveWrapper").hide();
}
});
AngularJS 代码
<div ng-show="payment == 'scheduled'">
<label>
<h4><b>Effective Date*</b></h4>
</label>
<input type="date" />
</div>
关于javascript - 如果仅选中某个单选按钮,则显示一个字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26228761/