You must have seen the pop-up menu when you browse the Web page. This article will introduce you to the foldable pop-up menu. If you are interested, refer
The Code is as follows:
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> foldable pop-up menu </title>
</Head>
<Style>
Body {background-color: # FFF; color: #000 ;}
Div {margin-bottom: 10px ;}
Ul. menu {display: none; list-style-type: none; margin-top: 5px ;}
A. menuLink {font-size: 16px; font-weight: bold ;}
</Style>
<Script type = "text/javascript">
Window. onload = initAll;
Function initAll (){
Var allLinks = document. getElementsByTagName ("");
For (var I = 0; I <allLinks. length; I ++ ){
If (allLinks [I]. className. indexOf ("menuLink")>-1 ){
AllLinks [I]. onclick = toggleMenu;
}
}
}
Function toggleMenu (){
Var startMenu = this. href. lastIndexOf ("/") + 1;
Var stopMenu = this. href. lastIndexOf (".");
Var thisMenuName = this. href. substring (startMenu, stopMenu );
Var thisMenu = document. getElementById (thisMenuName). style;
If (thisMenu. display = "block "){
ThisMenu. display = "none ";
}
Else {
ThisMenu. display = "block ";
}
Return false;
}
</Script>
<Body>
<H1> Shakespeare's Plays
<Div>
<A href = "menu1.html" class = "menuLink"> Comdeis </a>
<Ul class = "menu" id = "menu1">
<Li> <a href = "pg1.html"> All's Well That Ends Well </a> </li>
<Li> <a href = "pg2.html"> As You Like It </a> </li>
<Li> <a href = "pg3.html"> Love's Labor's Lost </a> </li>
<Li> <a href = "pg4.html"> The Comedy of Errors </a> </li>
</Ul>
</Div>
<Div>
<A href = "menu2.html" class = "menuLink"> Tragedies </a>
<Ul class = "menu" id = "menu2">
<Li> <a href = "pg5.html"> Anthony & Cleopatra </a> </li>
<Li> <a href = "pg6.html"> Hamlet </a> </li>
<Li> <a href = "pg7.html"> Romeo & Juliet </a> </li>
</Ul>
</Div>
<Div>
<A href = "menu3.html" class = "menuLink"> Histories </a>
<Ul class = "menu" id = "menu3">
<Li> <a href = "pg8.html"> Henry IV, Part1 </a> </li>
<Li> <a href = "pg9.html"> Henry IV, Part2 </a> </li>
</Ul>
</Div>
</Body>
</Html>