我有以下代碼。是否有一種智能的方法可以在切換單選按鈕之後禁用文本框並清除其值?單選按鈕之間切換後禁用文本框
<div class="checkbox">
<label style="margin-bottom:10px">Number of...:</label>
<div class="input-group" style="margin-bottom:10px">
<input class="radio" name="2" type="radio" checked="checked" id="numOfRadio" style="display:block;float:left">
<input class="form-control" name="numOf" type="number" placeholder="1000" value="1000" id="numOf" style="width:140px" />
<label for="radio_2" style="font-weight:400"><input type="radio" name="2" id="radioAll" style="margin-left" />All</label>
</div>
</div>
我嘗試使用下面的代碼,但它並沒有幫助:
$('.radio').on('click', function() {
$('.radio')
.siblings()
.prop('disabled', true);
$(this)
.siblings()
.prop('disabled', false);
});
那你嘗試添加此功能? – RRK
我添加了上面的代碼。 – Omri
@Omri嗨,請查看Rejith R Krishnan編輯的答案!乾杯。 :) – MrBuggy