jQuery in Action, 2nd edition*
The moose likes HTML, CSS and JavaScript and the fly likes change the style/color of a disabled component Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "change the style/color of a disabled component" Watch "change the style/color of a disabled component" New topic
Author

change the style/color of a disabled component

jonathan Greens
Ranch Hand

Joined: Apr 07, 2004
Posts: 139
how do I change the style/color of a disabled input component like text. A input component is grayed out by default when it's disabled. For example, I want to change the text color of <input type="text" value="hello" disabled> . I tried setting attribute style="color:black" but it doesn't work. Any idea?
thanks
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
You need to set it to readOnly="true" to be able to style the element.

Eric
jonathan Greens
Ranch Hand

Joined: Apr 07, 2004
Posts: 139
Ok I tried:
<input type="text" name="description" class="textarea1" readonly="false" disabled>and
<input type="text" name="description" class="textarea1" readonly="true" disabled>
and .textarea1{
color: black;
background-color:blue;
}
the color does not change to black, the blackground-color works ok. This is true regardless wheather readonly is set to true or false.
Is there a way to change the disabled text color?
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
you do not use disabled at all, you only use the read only property.
jonathan Greens
Ranch Hand

Joined: Apr 07, 2004
Posts: 139
thanks that helps. But what about for checkboxes? I set readOnly to true for checkboxes but i can still change them.
Niki Nono
Ranch Hand

Joined: Mar 20, 2005
Posts: 256
when u handle the event first, enable the element do what you want with it and then disable it again.


Life called,so here I am.<br />Cheers<br />Niki.:-)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: change the style/color of a disabled component