用JS弄的二级导航没效果 求大神看看_html/css_WEB-ITnose
HTML代码
<script></script>
<script>var def=1;</script>
<script></script>
<script>bannerHover("menu-parent",0)</script>
<script></script>
-----------------------------------------------------------------------------------
css样式:
#nav {
width:100%;
height:71px;
font-size:12px;
background-image:url(images/nav.gif);
}
#nav_menu {
width:1003px;
height:36px;
padding-top:7px;
}
#menu_parent {
padding-left:124px;
height:36px;
font-size:12px;
}
#menu_parent li {
height:36px;
line-height:36px;
text-align:center;
float:left;
list-style:none;
}
#menu_parent .nav_li01 {
width:93px;
}
#nav ul .nav_li02 {
width:1px;
background:url(images/nav_gd_bg.gif) no-repeat;
}
.nav_li01 a:link, .nav_li01 a:visited {
color:#FFF;
text-decoration:none;
display:block;
}
.nav_li01 a:hover, .nav_li01 a:active {
color:#CCC;
text-decoration:none;
background:url(images/nav_hover.gif) no-repeat;
display:block;
}
.nav_li01hover {
width:93px;
height:36px;
line-height:36px;
text-align:center;
display:block;
background:url(../images/nav_hover.gif) no-repeat;
text-decoration:none;
}
.nav_li01hover a:link, .nav_li01hover a:visited {
color:#DDD;
text-decoration:none;
}
/*sub_nav start*/
#sub_nav {
width:100%;
height:28px;
clear:both;
}
#sub_box {
/* width:755px;*/
width:848px;
margin:auto;
height:28px;
padding-left:124px;
padding-right:124px;
}
#sub_box div {
height:28px;
line-height:28px;
color:#999999;
display:none;
}
#sub_box a {
color:#999999;
text-decoration:none;
}
#sub_box a:hover, #sub_box a:active {
color:#EC0000;
}
#son1 {
margin-left:24px;
}
#son2 {
margin-left:112px;
}
#son3 {
margin-left:205px;
}
#son4 {
margin-left:299px;
}
#son5 {
margin-left:395px;
}
#son6 {
margin-left:138px;
}
#son7 {
margin-left:570px;
}
#son8 {
margin-left:675px;
}
#son9 {
margin-left:730px;
}
/*sub_nav end*/
------------------------------------------------------------------------------------
common.js文件:
function ymshow(num)
{
document.getElementById("ymzc").style.display="none";
document.getElementById("ymys").style.display="none";
document.getElementById(num).style.display="block";
}
function bannerHover(name, now) {
var thisul = document.getElementById(name);
var thisli = thisul.getElementsByTagName("li");
var thistotal = thisli.length;
for (var i = 0; i if (i == now) {
thisli[i].className = "dhhover";
thisli[i].onmouseout = function() {
this.className = "dhhover";
}
}
else {
thisli[i].className = "dhMove";
}
}
}
function meiti(num,str) {
document.getElementById("mei01").style.display = "none";
document.getElementById("mei02").style.display = "none";
document.getElementById("MDesign").style.display = "none";
document.getElementById("MInternet").style.display = "none";
document.getElementById(num).style.display = "";
document.getElementById(str).style.display = "";
}
function seoshow(num, str) {
document.getElementById("baiduseo").style.display = "none";
document.getElementById("gugeseo").style.display = "none";
document.getElementById("baiducontent").style.display = "none";
document.getElementById("gugecontent").style.display = "none";
document.getElementById(num).style.display = "";
document.getElementById(str).style.display = "";
}
function bannerHover(name, now) {
var thisul = document.getElementById(name);
var thisli = thisul.getElementsByTagName("li");
var thistotal = thisli.length;
for (var i = 0; i var num=i+1;
if (i == now) {
thisli[i].className = "nav_li01hover";
thisli[i].onmouseout = function() {
this.className = "nav_li01hover";
}
}
else if(num%2==1) {
thisli[i].className = "nav_li01";
}else
{
thisli[i].className = "nav_li02";
}
}
}
--------------------------
m.js文件:
var mcontainm=document.getElementById("menu-parent").getElementsByTagName("a");
var mcontains=document.getElementById("sub_box").getElementsByTagName("div");
for(var mi=0;mi mcontainm[mi].onmouseover=function(){mover(this.id.replace("par",""));}
mcontains[mi].onmouseover=function(){mover(this.id.replace("son",""));}
mcontainm[mi].onmouseout=function(){mout(this.id.replace("par",""));}
mcontains[mi].onmouseout=function(){mout(this.id.replace("son",""));}
}
if(def!=null){document.getElementById("par"+def).className="menuA";document.getElementById("son"+def).style.display="block";}
public.js文件很长 就不发了 但应该与它无关。
回复讨论(解决方案)
光看你这么长的代码,也没排好顺序,估计大家 都晕了……
已经自行解决了

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

热门话题

HTML适合初学者学习,因为它简单易学且能快速看到成果。1)HTML的学习曲线平缓,易于上手。2)只需掌握基本标签即可开始创建网页。3)灵活性高,可与CSS和JavaScript结合使用。4)丰富的学习资源和现代工具支持学习过程。

HTML定义网页结构,CSS负责样式和布局,JavaScript赋予动态交互。三者在网页开发中各司其职,共同构建丰富多彩的网站。

AnexampleOfAstartingTaginHtmlis,beginSaparagraph.startingTagSareEssentialInhtmlastheyInitiateEllements,defiteTheeTheErtypes,andarecrucialforsstructuringwebpages wepages webpages andConstructingthedom。

WebDevelovermentReliesonHtml,CSS和JavaScript:1)HTMLStructuresContent,2)CSSStyleSIT和3)JavaScriptAddSstractivity,形成thebasisofmodernWebemodernWebExexperiences。

GiteePages静态网站部署失败:404错误排查与解决在使用Gitee...

网页批注功能的Y轴位置自适应算法本文将探讨如何实现类似Word文档的批注功能,特别是如何处理批注之间的间�...

实现图片点击后周围图片散开并放大效果许多网页设计中,需要实现一种交互效果:点击某张图片,使其周围的...

HTML、CSS和JavaScript是Web开发的三大支柱。1.HTML定义网页结构,使用标签如、等。2.CSS控制网页样式,使用选择器和属性如color、font-size等。3.JavaScript实现动态效果和交互,通过事件监听和DOM操作。
