<title>无标题文档</title>
<script type="text/javascript">
function m()
{
var ele = document.getElementById('a');
ele.style.backgroundColor = 'red';//点击后背景变红了。
//这里写什么代码,可以将下面的aaa文字颜色在点击后变绿。
}
</script>
</head>
<body>
<a id="a" href="javascript:m()">aaa</a>
</body>
</html>

解决方案 »

  1.   

    CSS visited <style type=“text/css”>
      <!--
      A:link {text-decoration: none; color:blue}
      A:visited { color:red; text-decoration:line-through }
      A:active { color:white; text-decoration:underline }
      A:hover {text-decoration:none;color:yellow;background-color:black}
      -->
      </style>
      

  2.   


    通过css伪类实现<html>
    <head>
    <style type=“text/css”>
    a:visited { color:green;}
    </style>
    </head>
    <body>
    <a href="#">test</a>
    </body>
    </html>
      

  3.   

    上面几位朋友的代码都不行的。我的问题的关键是://这里写什么代码,可以将下面的aaa文字颜色在点击后变绿。注意,是在点击后变颜色!代码怎么写。
      

  4.   


    方法很多用css伪类就可以实现用JQUERY也能实现 <script type="text/javascript">
            $(function() {
                $("#a").click(function() {
                    $(this).css("color", "red");
                });
            });
        </script>
      

  5.   

    不想用jquery实现,请楼上的赐教如何用伪类实现。 
      

  6.   

    a:link ->a:hover ->a:active ->a:visited这四个是分别是:未访问时,鼠标在A标签上面时,激活时,己访问样式定义顺序也得按这个来在visited变色就可以了
      

  7.   


    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %><%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %><!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 runat="server">
        <title></title>       
        <script type="text/javascript">
            function m() {
                var ele = document.getElementById('a');
                ele.style.backgroundColor = 'red'; //点击后背景变红了。
                ele.style.color = "green";
            }
    </script>
    </head>
    <body>
    <a id="a" href="javascript:m()">aaa</a>
    </body>
    </html>
      

  8.   

    <title></title>   
    <script type="text/javascript">
    function m()
    {
    var ele = document.getElementById('head');
    //不指定a的id,而只指定了其上一层div的id。在这种情况下,如何能使aaa在点击后变红呢?
    }
    </script>
    </head>
    <body>
    <div id="head">
    <a href="javascript:m()">aaa</a>
    </div>
    </body>
    </html>
      

  9.   

    window.onload=function(){
    var as=document.getElementById('head').getElementsByTag('a');
    for(var i=0;i<as.length;i++){
         as[i].onclick=function(){as[i].style['color']='red';return true;}
    }
    }说了半天就是求代码老
    楼上几个说这么清楚也不看看
      

  10.   


    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <style type="text/css">
    a:visited {color:green;}
    </style>
    </head>
    <body>
    <a id="test" href="#">test</a>
    </body>
    </html>
    上面的代码之所以不行,因为双引号用了全角