这代码错在哪里了?帮忙找下错谢谢啦
function GetObj(objName)
{
if(document.getElementById)
{
return eval('document.getElementById("' + objName + '")');
}
else if(document.layers)
{
return eval("document.layers['" + objName +"']");
}
else
{
return eval('document.all.' + objName);
}
}
function Addid(preFix,classnumber,classname)
{
switch (classnumber)
{
case 1:
GetObj(classname).style.filter="progid:DXImageTransform.Microsoft.Shadow(Color=#333333,Direction=120,strength=5);";
for (var i=0; i<9;i++)
{
if (i!=1) GetObj(classname).style.filter = "none";
}
break;
case 2:
GetObj(classname).style.filter="progid:DXImageTransform.Microsoft.Shadow(Color=#333333,Direction=120,strength=5);";
for (var i=0; i<9;i++)
{
if (i!=2) GetObj(classname).style.filter = "none";
}
break;
}
}
<body>
<div id="topnav">
<ul>
<li id="news_lbl_0" class="topNo1" onclick="Addid('news',1,this.id)">
<a>首页</a></li>
<li id="news_lbl_1" class="topNo2" onclick="Addid('news',2,this.id)">
<a>网络学堂</a></li>
<li id="news_lbl_2" class="topNo3">
<a>搜罗天下</a></li>
<li id="news_lbl_3" class="topNo4">
<a>博客</a></li>
<li id="news_lbl_4" class="topNo5">
<a>专栏</a></li>
<li id="news_lbl_5" class="topNo6">
<a>免费广告</a></li>
<li id="news_lbl_6" class="topNo7">
<a>下载专区</a></li>
<li id="news_lbl_7" class="topNo8">
<a>论坛</a></li>
</ul>
</div>
</body>
——————————————————————————————————————————————————————
为什么我点击标签后没有反应呢,我的意思是点击某个标签后它有突显效果,而其它没有点击的标签样式不变
------解决方案--------------------function Addid(preFix,classnumber,classname) //classnumber是不是你要做效果的标签?
{
switch (classnumber)
{
case 1:
GetObj(classname).style.filter="progid:DXImageTransform.Microsoft.Shadow(Color=#333333,Direction=120,strength=5);"; //这里设置好了
for (var i=0; i <9;i++)
{
if (i!=1) GetObj(classname).style.filter = "none"; //这里又把他取消了
}
break;
case 2:
GetObj(classname).style.filter="progid:DXImageTransform.Microsoft.Shadow(Color=#333333,Direction=120,strength=5);";
for (var i=0; i <9;i++)
{
if (i!=2) GetObj(classname).style.filter = "none";
}
break;
}
}