每次点击a标签的时候 需要进行样式的切换。
就是说点击哪个a标签,这个标签的 id就 等于 <a id="cc">
其他标签的id就设置为无
----------------样式
@charset "utf-8";
/* CSS Document */body{
font-size:12px;
margin:0 auto;
font-family:"宋体";
line-height:20px;
width:97%;
}
*{
margin:0px;
padding:0px;}
img{
border-width:0px;}
#main{
width:97%;
margin:5px auto;
}
/*-----------------------------set of position----------------*/
.position,.pos_content,.notice,.infor_cc{
width:97%;
float:left;
border:#9fd6ff 1px solid;}
.position{
height:24px;
color:#014f8a;
background:url(../images/position.jpg) repeat-x 1px top;
line-height:24px;}
.position h1,.infor_cc h2{margin-left:13px;
padding-left:15px;
float:left;
display:inline;
font-size:12px;
font-weight:normal;}
.position h1{
background:url(../images/dot.jpg) no-repeat left 5px;}
.pos_content{
background:#f2f9ff;
color:#014f8a;
height:40px;
line-height:40px;
margin-bottom:15px;
}
/*-----------------------------------set of main_content----------------*/
.main_content{
width:97%;}
.main_title{
width:92%;
border-bottom:#0783df 2px solid;
height:22px;
padding-left:5%;
line-height:24px;}
.main_title a{
float:left;
display:inline-block;
margin-right:2px;
display:inline;
text-align:center;
width:100px;
}
.main_title a:link,.main_title a:visited,.main_title a:active{
color:#014f8a;
background:url(../images/tab_bg.jpg) no-repeat left top;
text-decoration:none;}
.main_title a#cc{
background:url(../images/cc_bg.jpg) no-repeat left top;
}
.main_title a#cc:link,.main_title a#cc:visited,.main_title a#cc:active{
color:#fff;
font-weight:bold;}
.main_title a:hover,.main_title a#cc:hover{
color:red;}
.notice{
color:#1d6402;
margin-top:5px;
background:#f2f9ff;
}
.infor_cc{
background:#f9f9f9;
line-height:26px;
height:26px;
color:#014f8a;
margin-top:3px;
margin-bottom:5px;
}
.infor_cc h2{
background:url(../images/dot1.jpg) no-repeat left 8px;
}table {
border-collapse:collapse;
border:solid #9fd6ff ;
border-width:1px 0 0 1px;
}
table th{
background:#c8e1fb;
color:#014f8a;
text-align:center;}
.td_blue{
color:#014f8a;}
table th,table td {border:solid #9fd6ff ;border-width:0 1px 1px 0;padding:2px;}
table td{
text-indent:1em;
color:#585858;}
.td_bg{
background:#f2f9ff;}
td a:link,td a:visited,td a:active{
color:#0000ff;
text-decoration:none;}
td a:hover{
color:red;}
------------------------
<div class="main_title">
<a href="#" id="cc" onclick="t()">个人信息 </a>
<a href="#" onclick="t2()">成本变动报告</a>
<a href="#" onclick="t3()">成本变动费用汇总</a>
</div>
就是说点击哪个a标签,这个标签的 id就 等于 <a id="cc">
其他标签的id就设置为无
----------------样式
@charset "utf-8";
/* CSS Document */body{
font-size:12px;
margin:0 auto;
font-family:"宋体";
line-height:20px;
width:97%;
}
*{
margin:0px;
padding:0px;}
img{
border-width:0px;}
#main{
width:97%;
margin:5px auto;
}
/*-----------------------------set of position----------------*/
.position,.pos_content,.notice,.infor_cc{
width:97%;
float:left;
border:#9fd6ff 1px solid;}
.position{
height:24px;
color:#014f8a;
background:url(../images/position.jpg) repeat-x 1px top;
line-height:24px;}
.position h1,.infor_cc h2{margin-left:13px;
padding-left:15px;
float:left;
display:inline;
font-size:12px;
font-weight:normal;}
.position h1{
background:url(../images/dot.jpg) no-repeat left 5px;}
.pos_content{
background:#f2f9ff;
color:#014f8a;
height:40px;
line-height:40px;
margin-bottom:15px;
}
/*-----------------------------------set of main_content----------------*/
.main_content{
width:97%;}
.main_title{
width:92%;
border-bottom:#0783df 2px solid;
height:22px;
padding-left:5%;
line-height:24px;}
.main_title a{
float:left;
display:inline-block;
margin-right:2px;
display:inline;
text-align:center;
width:100px;
}
.main_title a:link,.main_title a:visited,.main_title a:active{
color:#014f8a;
background:url(../images/tab_bg.jpg) no-repeat left top;
text-decoration:none;}
.main_title a#cc{
background:url(../images/cc_bg.jpg) no-repeat left top;
}
.main_title a#cc:link,.main_title a#cc:visited,.main_title a#cc:active{
color:#fff;
font-weight:bold;}
.main_title a:hover,.main_title a#cc:hover{
color:red;}
.notice{
color:#1d6402;
margin-top:5px;
background:#f2f9ff;
}
.infor_cc{
background:#f9f9f9;
line-height:26px;
height:26px;
color:#014f8a;
margin-top:3px;
margin-bottom:5px;
}
.infor_cc h2{
background:url(../images/dot1.jpg) no-repeat left 8px;
}table {
border-collapse:collapse;
border:solid #9fd6ff ;
border-width:1px 0 0 1px;
}
table th{
background:#c8e1fb;
color:#014f8a;
text-align:center;}
.td_blue{
color:#014f8a;}
table th,table td {border:solid #9fd6ff ;border-width:0 1px 1px 0;padding:2px;}
table td{
text-indent:1em;
color:#585858;}
.td_bg{
background:#f2f9ff;}
td a:link,td a:visited,td a:active{
color:#0000ff;
text-decoration:none;}
td a:hover{
color:red;}
------------------------
<div class="main_title">
<a href="#" id="cc" onclick="t()">个人信息 </a>
<a href="#" onclick="t2()">成本变动报告</a>
<a href="#" onclick="t3()">成本变动费用汇总</a>
</div>
<a href="#" id="cc" onclick="t()">个人信息 </a>
<a href="#" onclick="t2()">成本变动报告</a>
<a href="#" onclick="t3()">成本变动费用汇总</a>
</div>样式的切换啊
点击--成本变动报告 的时候 它的 A标签 id 就设置为 cc
其他A标签的 id 为没有
{
var a = document.getElementsByTagName("A");
for(var i=0;i<a.length;i++)
{
a[i].id="";
}
o.id="cc";
}
我要的就是改变ID啊 O 是传的什么啊?
<a href="#" onclick="t(this)">个人信息 </a>
<a href="#" onclick="t(this)">成本变动报告</a>
<a href="#" onclick="t(this)">成本变动费用汇总</a>var lastobj="";
function t(obj)
{
if (lastobj!="") getElementById(lastobj).classname="普通状态"; //普通状态要替换
obj.classname="infor_cc"; //infor_cc这里根据要求替换
lastobj=obj.id;
}