Create a tree directory menu

Source: Internet
Author: User
Production method:
Step 1: embed the code. Copy the following code to the  
<Style>
<! --
# Foldheader {cursor: hand; font-weight: bold;
List-style-image: url(fold.gif )}
# Foldinglist {list-style-image: url(list.gif )}
// -->
</Style>
<Script language = "JavaScript1.2">
<! --
/**
* Based on Folding Menu Tree
* Dynamic Drive (www.dynamicdrive.com)
* For full source code, installation instructions,
* 100's more DHTML scripts, and Terms
* Use, visit dynamicdrive.com
*
* Updated to support arbitrarily nested lists
* By Mark Quinn (mark@robocast.com) November 2nd 1998
*/
Var head = "display :''"
Img1 = new Image ()
Img1.src = "fold.gif"
Img2 = new Image ()
Img2.src = "open.gif"
Function change (){
If (! Document. all)
Return
If (event. srcElement. id = "foldheader "){
Var srcIndex = event. srcElement. sourceIndex
Var nested = document. all [srcIndex + 1]
If (nested. style. display = "none "){
Nested. style. display =''
Event. srcElement. style. listStyleImage = "url(open.gif )"
}
Else {
Nested. style. display = "none"
Event. srcElement. style. listStyleImage = "url(fold.gif )"
}
}
}
Document. onclick = change
// -->
</Script>
    
Step 2: create a menu. Insert the code to the place where the tree directory appears on the page. The following is a sample code:
<Li id = "foldheader"> News
<Ul id = "foldinglist" style = "display: none" style = & {head};>
CNN
ABC News
Vancouver Sun
<Li id = "foldheader"> Games
<Ul id = "foldinglist" style = "display: none" style = & {head};>
GameSpot
Happy Puppy
Game Center
<Li id = "foldheader"> Software
<Ul id = "foldinglist" style = "display: none" style = & {head};>
Outer 1
Outer 2
<Li id = "foldheader"> Nested

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.