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);     }); }); 

demo

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

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -