[英]Jquery Enable/Disable checkbox
當頁面具有一組以上的datepicker時,我試圖使此代碼正常工作。
如果您選擇選項“我目前在這里工作”,那么這會影響兩個組,而我只想影響當前的組。
$('.current-work-status').change(function () {
$('.form-control-2').prop('disabled', $(this).is(':checked'));
});
嘗試
$('.current-work-status').change(function () {
$(this).closest('div').prev().find('.form-control-2').prop('disabled', this.checked);
});
嘗試
使用jQuery .parents()選擇器查找組的父級,並使用.find()獲取.form-control-2
和update屬性。
$('.current-work-status').change(function () {
$(this).parents('div.row').find('.form-control-2').prop('disabled', $(this).is(':checked'));
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.