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+

gotbahn
  • 466
  • 2
  • 4
  • 18

5 Answers5

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.

Community
  • 1
  • 1
Fabrizio Calderan
  • 120,726
  • 26
  • 164
  • 177
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.

user229044
  • 232,980
  • 40
  • 330
  • 338
Alexander Zwitbaum
  • 4,776
  • 4
  • 48
  • 55
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.

Shiv Kumar Ganesh
  • 3,799
  • 10
  • 46
  • 85
0

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

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

This should help, :)

code

$('.problem').css('color', 'blue');​
Tats_innit
  • 33,991
  • 10
  • 71
  • 77
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

Engineer
  • 47,849
  • 12
  • 88
  • 91