日期:2014-05-17  浏览次数:20675 次

disabled后input样式
input type=text设置disabled=true后,字体颜色都是变灰,可否在css里设置disabled后的样式?
或者其他替代方案。

PS: readonly因之前测试有导致取不到值,作为最后的方案再测试……

------解决方案--------------------
哦,难怪楼主用disabled。
不过我没有遇到过readonly取不到值的情况。


不知道在js里面可不可以设置呢?
比如 document.getElementById("").style='XXXX';
------解决方案--------------------
单独设置一套样式.disabled
每次调用。。
貌似比较麻烦。。

等待高手
------解决方案--------------------
<input id="txtTextBox" type="text" value="AAA" onkeydown="return false;" onpaste="return false;" />

没有实际disable掉 只是屏蔽了onkeydown 和 onpaste 事件 不知道行不行
------解决方案--------------------
探讨
单独设置一套样式.disabled
每次调用。。
貌似比较麻烦。。

等待高手

------解决方案--------------------
没听说过readonly会取不到值,只知道disabled后取不到值
------解决方案--------------------
readonly + css
L@_@K
HTML code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
  <title> new document </title>
  <meta name="generator" content="editplus" />
  <meta name="author" content="" />
  <meta name="keywords" content="" />
  <meta name="description" content="" />
  <style type="text/css">
.myDisabled
{
    background-color: #808080;
    border: 1px solid red;
    color: white;
}
  </style>
 </head>

 <body>
    <input type="text" value="文本1 disabled=true" disabled="true" />
    <br />
    <input type="text" value="文本2 readonly=true" readonly="true" />
    <br />
    <input type="text" value="文本3 class=myDisabled" readonly="true" class="myDisabled" />
 </body>
</html>

------解决方案--------------------
readonly可以取到值,disabled取不到值.

HTML code

<html>
<head>
<style type="text/css">
.read { color:gray; }
</style>
</head>
<body>
<input type="text" value="test" readOnly class="read" />
</body>
</html>