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

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -