我想要使用單選按鈕禁用我的一些div,單選按鈕應該禁用並啓用div按照radion按鈕。我希望它仍然顯示,但你不能讓任何輸入或更改到輸入框使用單選按鈕禁用div
這裏是div
<div class="form-group">
<label for="name" class="col-sm-2 text-left"> Apakah Penerima KPS/PKH
</label>
<div class="col-sm-10 radio text-left">
<label>
<input type="radio" value="Ya" class="radio_penerima_kps" name="radio_penerima_kps" id="penerima_kps_ya">
Ya
</label>
<label>
<input type="radio" value="Tidak" class="radio_penerima_kps" name="radio_penerima_kps" id="penerima_kps_tidak" >
Tidak
</label>
</div>
</div>
<div id="form_kps">
<div class="form-group">
<label for="name" class="col-sm-2 text-left">No. KPS/PKH
</label>
<div class="col-sm-5">
<input type="text" class="form-control" placeholder="" id="nomor_kps_pkh" name="nomor_kps_pkh" value="<[email protected]$registration->nomor_kps_pkh?>" onchange="update_data()">
</div>
</div>
<div class="form-group">
<label for="name" class="col-sm-2 text-left">Usulan dari sekolah layak PIP
</label>
<div class="col-sm-5">
<input type="text" class="form-control" placeholder="" id="usulan_sekolah_layak_pip" name="usulan_sekolah_layak_pip" value="<[email protected]$registration->usulan_sekolah_layak_pip?>" onchange="update_data()">
</div>
</div>
<div class="form-group">
<label for="name" class="col-sm-2 text-left">Alasan Layak
</label>
<div class="col-sm-5">
<input type="text" class="form-control" placeholder="" id="alasan_layak" name="alasan_layak" value="<[email protected]$registration->alasan_layak?>" onchange="update_data()">
</div>
</div>
</div>
這裏的代碼是我使用的JavaScript代碼。
$(".radio_penerima_kps").click(function() {
if($(this).val() == "Ya"){
$("#nomor_kps_pkh").prop("disabled", false);
$("#usulan_sekolah_layak_pip").prop("disabled", false);
$("#alasan_layak").prop("disabled", false);
}else{
$("#nomor_kps_pkh").prop("disabled", true);
$("#usulan_sekolah_layak_pip").prop("disabled", true);
$("#alasan_layak").prop("disabled", true);
}
});
是否要禁用div或表單,對不起? – jjoselon
我的不好,div – Kelpie
你是什麼意思「禁用div」?把它藏起來? Div是不是你可以禁用... – Dekel