I have a HTML div
element on a page that is updated when a select
element on the page changes. Sometimes the input
tags (text boxes) need to be disabled based on the selection.
Here is the problem: the project stakeholders like the functionality, they just think in the "disabled" state, the text box contents are too light and therefore unreadable. Can I apply CSS to a disabled control? Or should I be setting the text boxes to readonly
and using some other CSS. This application is also using jQuery, if that helps. And ideas or suggestions here?
To make the disabled button, we will use the Pure CSS class “pure-button-disabled” with the class “pure-button”. We can also create a disabled button using disabled attribute. Disabled Button used Class: pure-button-disabled: It is used to disable the Pure CSS button.
An element can be disabled in HTML by setting disable property to true and enabled again by setting disabled=false. By using jQuery, you can grab the element you want to enable or disable and change this property by using the prop() or attr() function, depending upon the version of jQuery you are using.
First step: swap the HTML elements order so that the <label> appears after the <input> . This will allow the styling rules to work as desired. Then for the fun bit: use CSS to position the labels for text inputs on the left hand side! input[type=radio]:disabled+label works like a sharm!
input[type="submit"][disabled="disabled"]
{
/* CSS here */
}
input[type="text"][disabled="disabled"]
{
/* CSS here */
}
input[type="button"][disabled="disabled"]
{
/* CSS here */
}
Works in every browser if the input tag is something like:
<input type="submit" disabled="disabled">
and if you want to change it when it is not disabled, just add this to your CSS
input[type="submit"]
{
/* CSS here */
}
input[type="text"]
{
/* CSS here */
}
input[type="button"]
{
/* CSS here */
}
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