Home >Web Front-end >HTML Tutorial >The secondary navigation made with JS does not work. Please take a look_html/css_WEB-ITnose

The secondary navigation made with JS does not work. Please take a look_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 12:17:34963browse

HTML代码

 





-----------------------------------------------------------------------------------

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 < thistotal; 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 < thistotal; 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.length-1;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文件很长 就不发了 但应该与它无关。


回复讨论(解决方案)

光看你这么长的代码,也没排好顺序,估计大家 都晕了……

已经自行解决了

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