Create a foldable pop-up menu using JavaScript

Source: Internet
Author: User

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>

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.