<style>
.btncls  
{  
width:200;
height:200;background-image:expression((this.disabled==true)?this.src="url(1.jpg)":this.src="url(2.jpg)");   
}  
input{background-color:expression((this.readOnly && this.readOnly==true)?"#f0f0f0":"")}
</style> 
<input  class="btncls" id="btncls" type="button" value="asdfasdfasdfas" disabled=true>
<input type="text" id="txt1" value="asdfas" >
<div onClick="javascript:window.document.getElementById('btncls').disabled=false">asdfa</div>
<div onClick="javascript:window.document.getElementById('btncls').disabled=true">asdfa</div>

解决方案 »

  1.   

    <style type="text/css">
    .bb{
    background-image: expression((this.disabled) ? "url(1.gif)" : "url(2.gif)");  
    background-color: buttonface;
    }
    </style><input class="bb" type="button" value="123456">
    <input class="bb" type="button" value="123456" disabled="disabled">
      

  2.   

    有必要吗 disabled的时候改className就行了嘛
      

  3.   

    LS的果然强,不过我还是建议用button标签。
    <HTML>
    <HEAD>
    <style>
    .btn{
     color: expression((this.parentNode.disabled==true)?this.src="button1.gif":this.src="button2.gif");
    }
    </style>
     </HEAD><BODY>
    <button><img align=absmiddle class=btn>确定</button>
    </BODY>
    </HTML>哈哈
      

  4.   

    button标签效果好很多啊,见 
    http://www.cscrm.net/noname2.html
      

  5.   

    兄弟啊,建议你放弃expression,效率真的有问题啊,我在测试代码的时候,卡死多次,实在要用就这样吧:
    <style type="text/css">
    input{background-color:expression((this.readOnly && this.readOnly==true)?this.style.backgroundColor="#FF0000":this.style.backgroundColor="#FFFFFF")}
    </style>
    --------------------------
    把this.backgroundCilor改成background-image:url() 应该就可以了,不过我没测试了,前面的测试成功,实在太卡啦。不行的话在说吧!
      

  6.   

    expression()和url()似乎不能一起使用,会有脚本是错误。产品的实际应用场景不是我所描述的那么简单。我们平时做小程序当然可以灵活使用了,正如xuStanly 所说的那样,代码重构的很大。不过我已经采取在服务器端输出控制css了,而不是在客户端通过expression控制了。谢谢大家了。
      

  7.   

    expression尽量少用!还是修改className吧,这个更稳妥!