This example describes the JAVASCRIPT+CSS implementation of the collapsible level two menu. Share to everyone for your reference, specific as follows:
. aspx file:
<%@ Page language= "C #" autoeventwireup= "true" codefile= "NavigateMenu.aspx.cs" inherits= "Navigatemenu"%> <! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
">
JS file:
function Domenu (obj) {
var items=obj.parentnode.getelementsbytagname ("ul");
var Itmul;
if (items.length>0) {
itmul=items[0];
}
if (itmul.classname!= "ex") {
cxall ();
Itmul.classname= "ex";
} else{
itmul.classname= "CX";
}
}
function Statup () {
cxall ();
}
function Cxall () {
var Uldom=document.getelementbyid ("Nav");
var items=uldom.getelementsbytagname ("ul");
for (Var i=0;i<items.length;i++)
{
items[i].classname= "CX";
}
}
Note Here is the problem of delayed loading, because the page loading needs to perform preprocessing operations Statup () method, JS written in a separate file or JS write in
Another way to do this is to write all of the JavaScript directly in
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
More readers interested in JavaScript-related content can view the site topics: "JavaScript Search Algorithm Skills Summary", "JavaScript animation effects and Skills summary", "JavaScript Error and debugging skills summary", " JavaScript data structure and algorithm skills summary, "javascript traversal algorithm and Skills summary" and "JavaScript Mathematical Computing Usage Summary"
I hope this article will help you with JavaScript programming.