Tuesday, June 4, 2024
 Popular · Latest · Hot · Upcoming
72
rated 0 times [  79] [ 7]  / answers: 1 / hits: 58918  / 10 Years ago, tue, april 1, 2014, 12:00:00

Is there a way to disable and gray out the checkbox label as well once the checkbox becomes disabled using Bootstrap and Jquery?



<div class=checkbox>        
<input id=accept name=accept type=checkbox value=True>
<label for=accept class=control-label>Incremental</label>
</div>


I am now using the bellow code to disable the checkbox:



 $(#accept).prop(disabled, true);

More From » jquery

 Answers
15

You can do it with CSS only





$(#accept).prop(disabled, true);

input[type=checkbox][disabled] + label {
color: #ccc;
}

<script src=https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js></script>
<div class=checkbox>
<input id=accept name=accept type=checkbox value=True>
<label for=accept class=control-label>Incremental</label>
</div>





Read http://css-tricks.com/almanac/selectors/c/checked/



Attribute selectors in CSS


[#71677] Sunday, March 30, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kylee

Total Points: 60
Total Questions: 119
Total Answers: 101

Location: Bonaire
Member since Wed, Mar 29, 2023
1 Year ago
;