var li = document.getElementById("active")
li.getElementsByTagName("a")[0].id = li.id;
li.getElementsByTagName("a")[0].id = li.id;
解决方案 »
- 求助js控制css样式的一段代码
- 如何获取父对象。。
- 请教js脚本在不同浏览器中执行效率的问题
- 求助:动态表单个数如果验证内容是否为空?
- easyui select动态赋值
- 怎么样可以把库连接写到HTC文件中?------马上给分
- 如何读取列表框可以多选后的值?
- 不查注册表,使用什么工具获得注册控件的clsid?
- 求助:对于html文件可以用document.write("<a href=?page="+n+">"+n+" "+"</a>");改变page变量值吗?
- 登陆页面验证后怎么同时通知登陆页面及其父页面啊
- 让createElement创建的div层,始终在屏幕的中央,位置怎么控制啊!
- 超简单的问题,求段JS代码!
...
}
改成:
#active a{
...
}
就可以实现
为何楼主要用js
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"><html>
<head>
<title>ZDnet Emulation Preview</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<style type="text/css">
<!--
/* CSS Tabs */
#navcontainer {
background: #369;
border-top: 1px solid #9CC;
font: normal normal 11px Verdana, Geneva, Arial, Helvetica, sans-serif;
}#navlist {
list-style: none outside none;
margin: 0;
padding: 0;
}@media all {
#navlist {
text-align: left
}
}#navlist li {
bottom: 11px;
display: inline;
line-height: 1.2em;
margin: 0;
padding: 0;
position: relative;
}html>body #navlist li {
background: #000;
margin: 0 3px 0 0;
padding: 4px 0px 4px 0;
}#navlist a, #navlist a:link, #navlist a:visited {
background: #900;
border: 1px solid #FFF;
bottom: 2px;
color: #FFF;
cursor: pointer;
display: inline;
height: 1em;
margin: 0;
padding: 3px 5px 3px 5px;
position: relative;
right: 2px;
text-decoration: none;
}#navlist a:hover {
background: #C00;
bottom: 1px;
color: #FFF;
position: relative;
right: 1px;
}#navlist a:active {
background: #999;
bottom: 0px;
color: #FFF;
position: relative;
right: 0px;
}#navlist li#active {
background: #369;
bottom: 13px;
display: inline;
margin: 0 3px 0 0;
padding: 0;
position: relative;
}html>body #navlist li#active {
background: #000;
margin: 0 4px 0 4px;
}#navlist #active a, #navlist #active a:link, #navlist #active a:visited, #navlist #active a:hover {
background: #369;
border-bottom: none;
border-left: 1px solid #9CC;
border-right: 1px solid #9CC;
border-top: 1px solid #9CC;
bottom: 0;
color: #FFF;
cursor: text;
margin: 0;
padding: 2px 5px 0 5px;
position: relative;
right: 0;
}
-->
</style>
</head> <body>
<h4></h4>
<br /><br /> <div id="navcontainer">
<ul id="navlist">
<!-- CSS Tabs -->
<li id="active"><a id="current" href="mid.html" target ="midframe"> 首 页 </a></li>
<li><a href="mid.html" target ="midframe"> 统 计 管 理 </a></li>
<li><a href="mid.html" target ="midframe"> 录 入 管 理 </a></li>
<li><a href="mid.html" target ="midframe"> 查 询 管 理 </a></li>
<li><a href="mid.html" target ="midframe"> 网 站 管 理 </a></li>
</ul>
</div>
</body>
</html>
<li><a href="mid.html" target ="midframe" onclick="f(this)"> 统 计 管 理 </a></li>
<li><a href="mid.html" target ="midframe" onclick="f(this)"> 录 入 管 理 </a></li>
<li><a href="mid.html" target ="midframe" onclick="f(this)"> 查 询 管 理 </a></li>
<li><a href="mid.html" target ="midframe" onclick="f(this)"> 网 站 管 理 </a></li>
<script language=javascript>
function f(obj){
var li = document.getElementById("active");
var objLi = obj.parentNode;
if(li != objLi){
li.removeAttribute("id");
objLi.setAttribute("id","active");
}
}
</script>