日期:2014-05-16 浏览次数:20412 次
<!DOCTYPE html>
<html>
<head>
<script>
var preEle;
function setStyle(e){
if(preEle!=null)preEle.style.color="yellow";
e.style.color="green";
preEle=e;
}
</script>
</head>
<body>
<div class="link">
<a href="#" target="_blank" onclick="setStyle(this)">链接1</a>
<a href="#" target="_blank" onclick="setStyle(this)">链接2</a>
<a href="#" target="_blank">链接3</a>
<a href="#" target="_blank">链接4</a>
<a href="#" target="_blank">链接5</a>
</div>
</body>
</html>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript" src="../js/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
$(function(){
$(".link").children("a").click(function(){
alert($(".link").children("a").length);
$(".link").children("a").css("color","").css("background-color","");
$(this).css("color","#000").css("background-color","red");
});
});
</script>
</head>
<body>
<div class="link">
<a href="#" >链接1</a>
<a href="#" >链接2</a>
<a href="#" >链接3</a>
<a href="#" >链接4</a>
<a href="#">链接5</a>
</div>
</body>
</html>