首页 >web前端 >html教程 >求助,网站导航栏样式js+css_html/css_WEB-ITnose

求助,网站导航栏样式js+css_html/css_WEB-ITnose

WBOY
WBOY原创
2016-06-24 12:18:461383浏览

<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");}

本来是想通过js改变标签的class来改变样式,可是执行的时候发现样式没有改变。刚学没多久,希望有朋友能帮助一下。


回复讨论(解决方案)

 eval(id)==> thisObj


eval(id).class sName="menu-c";
改成
thisObj.className="menu-c";

className你多写了个s

多谢,我还以为是语法上不支持这样的操作呢

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn