jquery - set checkbox disabled or readonly when its checked -
is possible set readonly or disabled attribute when user checked checkbox ?
<div class="form-group"> <div class="col-sm-offset-2 col-sm-10"> <div class="checkbox"> <label> <input type="checkbox" name="checkbox" id="checkbox"> remember me </label> </div> </div>
update :
i tried this:
$(document).ready(function() { $("input:checkbox[name='checkbox']").change(function() { this.prop('readonly', true); }); });
try way. have said in comment once disabled checkbox there no way can enable again maybe need change approach in doing this.
use selector id
, use prop disabled
disabled checkbox not readonly
$(document).ready(function() { $("#checkbox").change(function() { if ($(this).is(':checked')) {//check if checkbox checked $(this).prop('disabled', true) } }); });
Comments
Post a Comment