Home >Web Front-end >HTML Tutorial >Please help, website navigation bar style js css_html/css_WEB-ITnose

Please help, website navigation bar style js css_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 12:18:461386browse

<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

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

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn