87,910
社区成员
发帖
与我相关
我的任务
分享
<!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=gb2312" />
<title>无标题文档</title>
<style type="text/css">
.noclick, .noclick a{
color:#0000FF;
}
.on_click, .on_click a{
color:#ff0000;
}
</style>
<script type="text/javascript">
function show1(_this){
var obj =_this.parentNode.parentNode.getElementsByTagName("div"),j=obj.length;alert
for (var i=0;i<j;i++)
obj[i].className = "noclick";
_this.parentNode.className = "on_click";
}
</script>
</head>
<body>
<div>
<div>
<div>
<div>
<div>
<div>
<div id="getmil" class="noclick">getmil <a href="#" onclick=show1(this)>get</a></div>
<div id="mil" class="noclick">mil <a href="#" onclick=show1(this)>input</a></div>
<div id="sendmail" class="noclick">sendmail <a href="#" onclick=show1(this)>send</a></div>
</div>
</div>
</div>
</div>
</div>
</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=gb2312" />
<title>无标题文档</title>
<style type="text/css">
.noclick, .noclick a{
color:#0000FF;
}
.on_click, .on_click a{
color:#ff0000;
}
</style>
<script type="text/javascript">
function show1(_this){
var obj =_this.parentNode.parentNode.getElementsByTagName("div"),j=obj.length;alert
for (var i=0;i<j;i++)
obj[i].className = "noclick";
_this.parentNode.className = "on_click";
}
</script>
</head>
<body>
<div id="getmil" class="noclick">getmil <a href="#" onclick=show1(this)>get</a></div>
<div id="mil" class="noclick">mil <a href="#" onclick=show1(this)>input</a></div>
<div id="sendmail" class="noclick">sendmail <a href="#" onclick=show1(this)>send</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=gb2312" />
<title>无标题文档</title>
<style type="text/css">
.normal, .normal a{
color:#0000FF;
}
.onclick, .onclick a{
color:#008800;
}
</style>
<script type="text/javascript">
function $(id){
return document.getElementById(id);
}
window.onload = function(){
var div = [$("div1"), $("div2"), $("div3")];
for(var i=0; i<div.length; i++){
div[i].onclick = function(){
for(var j=0; j<div.length; j++){
div[j].className = "onclick";
};
};
}
};
</script>
</head>
<body>
<div id="div1" class="normal">文字 <a href="#">链接</a></div>
<div id="div2" class="normal">文字 <a href="#">链接</a></div>
<div id="div3" class="normal">文字 <a href="#">链接</a></div>
</body>
</html>
<script>
function changech(a){
var i=1
for(i=1;i<5;i++){
var b='c'+i;
var c='d'+i;
if(a!=b){
document.getElementById(b).style.background='url(images/01.gif) repeat-x';
document.getElementById(b).style.color='#5c5c5c';
document.getElementById(c).style.display='none';
}
else{
document.getElementById(b).style.background='url(images/bar_bg.gif) repeat-x';
document.getElementById(b).style.color='#ff0000';
document.getElementById(c).style.display='block';
}
}
}
</script>
这就是一个div控制三个div的JavaScript