RT 想用JavaScript得到我的链接的颜色可以吗??

解决方案 »

  1.   

    ?  好象难取道CSS中的颜色哦,关注
      

  2.   


    <style>
    a.as{color:red}
    </style>
    <a class="as" id=as>as</a>
    <script language="javascript">
    <!--
    alert(document.getElementById("as").currentStyle.color)//-->
    </script>
      

  3.   

    <style>
    a.as{color:red}
    </style>
    <a class="as" id=as>as</a>
    <script language="javascript">
    <!--
    var CurrentStyle = function(element){
    return element.currentStyle || document.defaultView.getComputedStyle(element, null);
    }
    alert(CurrentStyle(document.getElementById("as")).color)//-->
    </script>
      

  4.   

    if(document.getElementById("aaa").currentStyle){
    alert(document.getElementById("aaa").currentStyle.backgroundColor);
    }else{
    alert(document.defaultView.getComputedStyle(document.getElementById("aaa"),null).backgroundColor);
    }