Heim >Web-Frontend >HTML-Tutorial >求助,网站导航栏样式js+css_html/css_WEB-ITnose
<div id=site-nav> <ul class=quick-menu> <li class="services menu-item last"> <div class=menu> <a id="a" class="menu-c" onclick="catalogClick('', '1','a')" target=_top>全部</a> </div> </li> <li class="services menu-item last"> <div class="menu"> <a id="b" class="menu-hd" onclick="catalogClick('5', '1','b')" target=_top>下载</a> </div> </li> <li class="services menu-item last"> <div class=menu> <a id="c" class="menu-hd" onclick="catalogClick('2', '1','c')" target=_top>关注</a> </div> </li> <li class="services menu-item last"> <div class="menu"> <a id="d" class="menu-hd" onclick="catalogClick('6', '1','d')" target=_top>评论</a> </div> </li> <li class="services menu-item last"> <div class="menu"> <a id="e" class="menu-hd" onclick="catalogClick('3', '1','e')" target=_top>收藏</a> </div> </li> <li class="services menu-item last"> <div class=menu> <a id="f" class="menu-hd" onclick="catalogClick('4', '1','f')" target=_top>分享</a> </div> </li> </ul> </div>
#site-nav .menu-hd { PADDING:0px; DISPLAY: block; Z-INDEX: 10002; CURSOR: pointer; POSITION: absolute; HEIGHT:50px; line-height:40px; width:76px; margin:0;}#site-nav .menu-c { PADDING:0px; DISPLAY: block; Z-INDEX: 10002; CURSOR: pointer; POSITION: absolute; HEIGHT:50px; line-height:40px; width:90px; background:url(img/catalog.png) no-repeat center top; margin:0;}#site-nav .menu:hover .menu-hd { height:50px; width:90px; background:url(img/catalog.png) no-repeat center top;}
function catalogClick(logType,pageCode,id) { var obj = document.getElementsByTagName("a"); for(var i=0;i<obj.length;i++) { if(obj[i].className == 'menu-c') { obj[i].className = "menu-hd"; break; } } id = trim(id); var thisObj = document.getElementById(id); eval(id).classsName="menu-c";}function trim(str) { if (str == null) { return ""; } return str.replace(/^\s*(.*?)[\s\n]*$/g, "$1");}
eval(id)==> thisObj
把
eval(id).class sName="menu-c";
改成
thisObj.className="menu-c";
className你多写了个s
多谢,我还以为是语法上不支持这样的操作呢