mardi 7 février 2017

Add disable class for label if checkbox is disabled using jQuery

I have this checkbox code

<div class="checkbox-group">

    <label class="fc-contain-sm checkbox-status">
        <input type="checkbox" class="formjs-checkbox-sm" checked disabled>
        <div class="fc-status-sm"></div>
        <span class="checkbox-lable-sm">Disabled checkbox</span>
    </label>

    <label class="fc-contain checkbox-status">
        <input type="checkbox" class="formjs-checkbox">
        <div class="fc-status"></div>
        <span class="checkbox-lable">Normal checkbox</span>
    </label>

</div>

And i want to add class disabled to checkbox-lable-sm class if the checkbox is disabled using jquery

css

.checkbox-group .disabled {
  cursor: not-allowed;
}

I have tried this code but it is not working

$('.checkbox-group > input:disabled.formjs-checkbox-sm').each(function(){
    $(this).find('.checkbox-lable-lg').addBack().addClass("disabled");
}); 




Aucun commentaire:

Enregistrer un commentaire