工作中遇到问题,麻烦大家给看一下儿,谢谢!
页面中有几个链接,分别套用css样式,初始化的时候只有第一个链接使用的是class="pb",我想通过点击当前的链接使当前的链接样式使用class="pb",其他的连接样式用class="pa"以加以区分,请问这个函数怎样写,我举了个例子,麻烦大家帮我改一下,谢谢大家!
<html>
<head>
<style type="text/css">
<!--
a.pa:link {
color: #000000;
text-decoration: none;
}
a.pa:visited {
color: #000000;
text-decoration: none;
}
a.pa:hover {
color: #FF0000;
text-decoration: underline;
}
a.pa:active {
color: #000000;
text-decoration: none;
}
a.pb:link {
color: #0000ff;
text-decoration: none;
}
a.pb:visited {
color: #0000ff;
text-decoration: none;
}
a.pb:hover {
color: #000000;
text-decoration: underline;
}
a.pb:active {
color: #0000ff;
text-decoration: none;
}
-->
</style>
<script language="javascript">
<!--
function fun(){
//var obj=document.getElementsByName("link");
//这个函数体怎样写
}
-->
</script>
</head>
<body>
<a href="#" class="pb" name="link" onClick="fun()">text1</a>
<a href="#" class="pa" name="link" onClick="fun()">text2</a>
<a href="#" class="pa" name="link" onClick="fun()">text3</a>
</body>
</html>