<script>
document.body.backgroundColor="red";
document.body.backgroundImage="url(another.jpg)";
</script>

解决方案 »

  1.   

    document.styleSheets[0].rules(".link").style.color="red"
    我这样写对吗?
    可是怎么不行呢??
      

  2.   

    事实上,我刚才使用
    document.styleSheets[0].rules("a:hover").style.color="red"
    处理也是document.styleSheets[0].rules.item(0).style.color="red",
    换成你改了的
    document.styleSheets[0].rules(".link").style.color="red"
    也是document.styleSheets[0].rules.item(0).style.color="red",
    本来是不能只用用CSS定义的名称的,但样式表的第一条刚好可以这样做
      

  3.   

    document.styleSheets[0].rules[1].style.color="red"
      

  4.   

    <script>
    var a=document.styleSheets[0].rules
    for(i=0;i<a.length;i++)
    if(a[i].selectorText==".link")a[i].style.color="red"
    </script>