本帖最后由 largegy 于 2011-07-03 09:52:14 编辑

解决方案 »

  1.   


    <!DOCTYPE html>
    <html>
        <head>
            <title>Test</title>
            <meta http-equiv="Content-Type" content="text/html;charset=gb2312" />
            <style type="text/css"><!--
    a:hover { color:red; }
            --></style>
        </head>
        <body>
    <a href="#" id="test">fffffffffffffffffff</a>
    <script>
    document.getElementById('test').style.background = 'blue'
    </script>
        </body>
    </html>没问题啊
    楼主 把 你得 demo 贴上来呢?
      

  2.   

    但是给a:hover加上图片背景就不行了,如果去掉js控制,图片背景就行显示出来,执行js后,图片背景就失效了!
    <!DOCTYPE html>
    <html>
        <head>
            <title>Test</title>
            <meta http-equiv="Content-Type" content="text/html;charset=gb2312" />
            <style type="text/css"><!--
                a:hover { color:red; background:url(nav2.gif)}
            --></style>
        </head>
        <body>
            <a href="#" id="test" >fffffffffffffffffff</a>
            <script>
    document.getElementById('test').style.background = 'blue' 
                 
            </script>
        </body>
    </html>
      

  3.   

    <script>
    document.getElementById('test').style.backgroundColor = 'blue'  
    </script>
    这样试试 。
      

  4.   

    把js中的background改为background-color就好``
      

  5.   

    这个document.getElementById('test').style.background = 'blue'  把a:hover中的background覆盖了.