日期:2014-05-16  浏览次数:20392 次

如何动态设定输入栏的背景色?
<input type="text" name="mytxt" style="background-color:#fff;">

当document.forms[0].mytxt.disabled=true; 时,
在IE下背景色不变,如何把背景色变成灰色?

------解决方案--------------------
没明白你啥意思

HTML code

<input type="text" name="mytxt" style="background-color:#fff;">
<script>
    document.forms[0].mytxt.disabled = true;
    document.forms[0].mytxt.style.background = "#999";

</script>

------解决方案--------------------
<input type="text" name="mytxt" id = "myText" style="background-color:#ddaa55;">
<input type="button" name="mybutton" id = "mybutton" value = "button">
<script type="text/javascript">
document.getElementById("myText").disabled = true;
document.getElementById("myText").style.background = "#000000";
document.getElementById("mybutton").disabled = true;

这个应该是浏览器的原因吧,比如你把button类型的禁用,在IE下可以看到效果,但是在FF下就没有效果,如果需要显示相同的话,就得自己做修改了。
------解决方案--------------------
document.forms[0].mytxt.style.border = "none";

------解决方案--------------------
你把输入框的样式都去掉,然后自定义一个样式