<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>
<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>
<!--
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>
通过css伪类实现<html>
<head>
<style type=“text/css”>
a:visited { color:green;}
</style>
</head>
<body>
<a href="#">test</a>
</body>
</html>
方法很多用css伪类就可以实现用JQUERY也能实现 <script type="text/javascript">
$(function() {
$("#a").click(function() {
$(this).css("color", "red");
});
});
</script>
<%@ 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>
<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>
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;}
}
}说了半天就是求代码老
楼上几个说这么清楚也不看看
<!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>
上面的代码之所以不行,因为双引号用了全角