<script   type="text/javascript"   language="javascript"> var   hr   =   document.getElementById('myHr'); 
hr.style.textAlign = 'left'</script>建议你去下载一下 DHTML 手册.chm 这样碰到这问题就可以查手册了

解决方案 »

  1.   

    js确实有很多细节问题hr.setAttribute("style","text-align:left");IE不支持这样,FF支持hr.style.text-align   =   "left"; IE和FF支持,只是你写错了,属性一定要有大小写
    而且不能沿用元素里添加的写法text-align应该这样hr.style.textAlign
      

  2.   

    可以用如下:
    hr.style.cssText = "text-algin:center; width:50%;";
      

  3.   

    L@_@K
    <!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="Gao YiXiang" />
        <meta name="email" content="[email protected]" />
        <meta name="keywords" content="javascript dhtml dom" />
        <meta name="description" content="I love web development." />
    </head>
    <body>
        <form   id="form1"   runat="server"> 
            <div> 
                    <hr   id="myHr"   /> 
            </div> 
        </form> 
            <script   type="text/javascript"   language="javascript"> 
            var   hr   =   document.getElementById('myHr'); 
            //可以通过下面方法设置宽度 
            hr.style.width="50%"; 
            
            // 任选其一皆可!
            hr.style.setAttribute("textAlign", "left");
            // 或
            //hr.style.textAlign   =   "left"; 
            </script> 
    </body>
    </html>
    送你三本手册!DHTML参考手册
    http://download.csdn.net/source/308913样式表中文手册
    http://download.csdn.net/source/304124JScript语言参考
    http://download.csdn.net/source/308916