I am working on Time Scheduling Calendar, At some point I need to put condition as if checkbox is checked and disabled, it would be always disable. So user can't uncheck it. For it, I had put following Condition. But it is not working.
if($(this).is(':checked') && $(this).is(':disabled')){
$(this).attr("disabled", true);
}
This is the Code where I'm working.. [for more clear Idea about what i'm asking]
$('input[type="checkbox"]').on('change', function() {
$(this).parent('label').nextAll('label').first().find('input[type="checkbox"]').prop('checked', $(this).is(':checked'));
$(this).parent('label').nextAll('label').first().find('input[type="checkbox"]').attr("disabled", $(this).is(':checked'));
$(this).parent('label').prevAll('label').first().find('input[type="checkbox"]').attr("disabled", $(this).is(':checked'));
a= $(this).parent('label').prevAll('label').first().find('input[type="checkbox"]');
if(a.is(':checked')){
a.attr("disabled",true);
}
if($(this).is(':checked')){ $(this).parent('label').prevAll('label').first().find('input[type="checkbox"]').attr("disabled", true);
}
if($(this).is(':checked') && $(this).is(':disabled')){
$(this).attr("disabled", true);
}
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<label><input type="checkbox" name="one" value="a"> 08:00</label><br/>
<label><input type="checkbox" name="one" value="b"> 08:30</label><br/>
<label><input type="checkbox" name="one" value="c"> 09:00</label><br/>
<label><input type="checkbox" name="one" value="c"> 09:30</label><br/>
<label><input type="checkbox" name="one" value="c"> 10:00</label><br/>
<label><input type="checkbox" name="one" value="f"> 10:30</label><br/>
<label><input type="checkbox" name="one" value="g" disabled> 11:00</label><br/>
Do Check 10:30
and 10:30 and 11:00 will checked and 10:00 disabled
Do Check 09:30
and 09:30 and 10:00 will check and 09:00 disabled
Do Uncheck 09:30
and 09:30 and 10:00 will Uncheck and 10:00 enbled, but 10:00 should be disabled