I have some labels like:
<label>
<input type="checkbox" name="the_name" id="the_name" /> Label text
</label>
that sometimes are disabled
$("#the_name").prop('disabled', true);
No problem, but I would like to change label text color to make it more visible. Is it possible using Jquery and/or CSS?
The DOM Input Color disabled Property in HTML DOM is used to set or return whether a color picker should be disabled or not. A Disabled element is usually is unusable and un-clickable and are usually grey in color by default in all the Browser.
You should use javascript or your templating engine to add and remove a "disabled" class to the label elements. It shouldn't be any difficult since having disabled elements already imply you are using some sort of programming with the forms.
To set the font color in HTML, use the style attribute. The style attribute specifies an inline style for an element. The attribute is used with the HTML <p> tag, with the CSS property color. HTML5 do not support the <font> tag, so the CSS style is used to add font color.
This can be done in CSS, but only when the label comes after the input tag. For example:
HTML:
<input id="someinput" type="text" /><label for="someinput">Type text:</label>
CSS:
input[disabled] + label { *whatever style you want when input is disabled* } ;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With