我也曾遇到类似问题后来我修改的是className (先定义一个样式)这个方法可行,也不复杂

解决方案 »

  1.   

    直接修改 cssText 是不刷新的,你需要 用 obj.style.setExpression("width","175"); 来改变样式表 或者简单的方法 你修改classname
      

  2.   

    <input type="text" onfocus="SetDefaultStyle(this,'333333','f0f8ff')" onblur="SetDefaultStyle(this,'cccccc','eeeeee')" />
    <script type="text/javascript">
    //<![CDATA[
        
    function SetDefaultStyle(obj,borderColor,bgColor)

      obj.style.cssText= "background-color:" +borderColor;
    }
    //]]>
    </script>
      

  3.   

    用CSS写一个Class。然后用事件更换Class
      

  4.   

    设置class属性
    非ie
    var e=document.getElementById("e")
    e.setAttribute("class","styleClass")
    ie
    var e=document.getElementById("e")
    e.setAttribute("className","styleClass")
      

  5.   

    重新看了下帖子,原来楼主字符串写错了啊,嗨
    <input type="text" onfocus="SetDefaultStyle(this,'333333','f0f8ff')" onblur="SetDefaultStyle(this,'cccccc','eeeeee')" /><div style="display:inline"></div>
    <script type="text/javascript">
        
    function SetDefaultStyle(obj,borderColor,bgColor)

      obj.style.cssText= "display:inline;width:175px;BORDER-RIGHT: #"+borderColor+" 1px solid; BORDER-TOP: #"+borderColor+" 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #"+borderColor+" 1px solid; BORDER-BOTTOM: #"+borderColor+" 1px solid; FONT-FAMILY: verdana; BACKGROUND-COLOR: #" + bgColor;
    //  alert(obj.cssText);
    }</script>
      

  6.   

    http://blog.csdn.net/xuStanly/archive/2006/09/10/1204692.aspx
    要不要试试圆角带阴影且焦点变色的文本框?