我有一個 chekbox 和一個文本框<input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"><input class="form-control" type="text" id="usr_zipcode" maxlength="10" name="usr_zipcode" required="required">如何制作 jquery,當 vehiche1 被選中但 usr_zipcode 為空或沒有值時,它禁用另一個復選框,名稱 checkme :<input type="checkbox" id="checkme">我嘗試使用下面的代碼但不起作用$('#vehicle1').change(function () { var input1 = $('#usr_zipcode'); input1.change( function() { var empty = ( input1.val() == '' ); $("#checkme").prop('checked', false); $("#checkme").attr('disabled','disabled'); });}).change();
如果復選框選中但輸入空禁用另一個復選框
三國紛爭
2021-06-08 08:04:08