1
<input class="problem" type="text" value="some text" disabled="disabled"> 

How can i change color of "some text"?

upd: Styling by CSS working only in Chrome & Mozilla. I need support of all browser including IE7+

3
  • using CSS is simle: color:#ff0000; will be red Commented Jul 4, 2012 at 11:29
  • Checkout the style="color:green" or any color would work in all browsers Commented Jul 4, 2012 at 11:32
  • Just add style, as show in the answers. Only one problem though, Opera doesn't color it when disabled. Commented Jul 4, 2012 at 11:32

5 Answers 5

3

just apply some css style, e.g.

.problem { color : red; } 

you can even define two different colours for both normal and disabled inputs like so;

.problem { color : red; } .problem[disabled] { color : #cfcfcf; } 

example fiddle: http://jsfiddle.net/dgNZS

On older IE versions is not possible change the colour of a disabled input element as already answered here but you can try to follow bobince's workaround.

Sign up to request clarification or add additional context in comments.

1 Comment

I'll just delete disabled="disabled". Thx
1

You can change the disable style of the textbox for all properties in all browsers, except the color of the text and only in the IE. For IE (for all properties except the text color) you must set the doctype to 4.01 strict, and then using the code like

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <style type="text/css"> input[disabled], input[readonly] { background-color: green; border: #3532ff 1px solid; color: #00FF00; cursor: default; } </style> </head> <body> <form> <input class="problem" type="text" value="some text" disabled="disabled"> </form> </body> </html> 

But if you use the readonly instead of disabled="disabled" like Engineer wrote this works also in the ie.

Comments

0

For cross-browser solution, you need to use readonly and unselectable attributes instead of disabled, and apply these styles:

.problem[readonly]{ color: red; /*Preventing selection*/ -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; /**/ }​ 

markup:

<input class="problem" type="text" value="some text" readonly unselectable="on"> 

DEMO

1 Comment

@Godban I have slightly improved my answer. Look again.
0

Give it a Style ie style="color:green"

<input class="problem" type="text" value="some text" disabled="disabled" style="color:green"> 

Or Include this in your class you give to input.

Comments

0

Demo http://jsfiddle.net/ELuXW/1/

API: CSS - http://api.jquery.com/css/

This should help, :)

code

$('.problem').css('color', 'blue');​ 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.