JavaScript Application-implement menu list expansion and Closure

Source: Internet
Author: User
Code:
  1. <! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <HTML xmlns = "http://www.w3.org/1999/xhtml">
  3. <Head>
  4. <Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
  5. <Title> untitled document </title>
  6. <Style type = "text/CSS">
  7. Table {
  8. Border: # 0066ff 1px solid;
  9. }
  10. Table TD {
  11. Border: # 0000ff 1px solid;
  12. Background-color: #00 CCFF;
  13. }
  14. Table TD Div {
  15. Background-color: #66 ffcc;
  16. Display: none;
  17. }
  18. Table td a: Link, table td a: visited {
  19. Text-Decoration: none;
  20. Color: #993300;
  21. }
  22. . Open {
  23. Display: block;
  24. }
  25. . Close {
  26. Display: none;
  27. }
  28. </Style>
  29. <SCRIPT type = "text/JavaScript">
  30. Function list2 ()
  31. {
  32. VaR anode = event. srcelement;
  33. VaR tdnode = anode. parentnode;
  34. VaR divnode = tdnode. getelementsbytagname ("Div") [0];
  35. // Alert (divnode. nodename );
  36. VaR tabnode = Document. getelementsbytagname ("table") [0];
  37. VaR divnodes = tabnode. getelementsbytagname ("Div ");
  38. For (VAR x = 0; x <divnodes. length; X ++)
  39. {
  40. If (divnodes [x] = divnode)
  41. {
  42. If (divnode. classname = "open ")
  43. {
  44. Divnode. classname = "close ";
  45. }
  46. Else
  47. {
  48. Divnode. classname = "open ";
  49. }
  50. }
  51. Else
  52. Divnodes [X]. classname = "close ";
  53. }
  54. }
  55. </SCRIPT>
  56. </Head>
  57. <Body>
  58. <Table>
  59. <Tr>
  60. <TD>
  61. <A href = "javascript: void (0)" onclick = "list2 ()"> friend menu list </a>
  62. <Div>
  63. Satan's defense against Satan's Law
  64. Satan's defense against Satan's Law
  65. Satan's defense against Satan's Law
  66. Satan's defense against Satan's Law
  67. Satan's defense against Satan's Law
  68. </Div>
  69. </TD>
  70. </Tr>
  71. <Tr>
  72. <TD>
  73. <A href = "javascript: void (0)" onclick = "list2 ()"> friend menu list </a>
  74. <Div>
  75. Satan's defense against Satan's Law
  76. Satan's defense against Satan's Law
  77. Satan's defense against Satan's Law
  78. Satan's defense against Satan's Law
  79. Satan's defense against Satan's Law
  80. </Div>
  81. </TD>
  82. </Tr>
  83. <Tr>
  84. <TD>
  85. <A href = "javascript: void (0)" onclick = "list2 ()"> friend menu list </a>
  86. <Div>
  87. Satan's defense against Satan's Law
  88. Satan's defense against Satan's Law
  89. Satan's defense against Satan's Law
  90. Satan's defense against Satan's Law
  91. Satan's defense against Satan's Law
  92. </Div>
  93. </TD>
  94. </Tr>
  95. <Tr>
  96. <TD>
  97. <A href = "javascript: void (0)" onclick = "list2 ()"> friend menu list </a>
  98. <Div>
  99. Satan's defense against Satan's Law
  100. Satan's defense against Satan's Law
  101. Satan's defense against Satan's Law
  102. Satan's defense against Satan's Law
  103. Satan's defense against Satan's Law
  104. </Div>
  105. </TD>
  106. </Tr>
  107. <Tr>
  108. <TD>
  109. <A href = "javascript: void (0)" onclick = "list2 ()"> friend menu list </a>
  110. <Div>
  111. Satan's defense against Satan's Law
  112. Satan's defense against Satan's Law
  113. Satan's defense against Satan's Law
  114. Satan's defense against Satan's Law
  115. Satan's defense against Satan's Law
  116. </Div>
  117. </TD>
  118. </Tr>
  119. <Tr>
  120. <TD>
  121. <A href = "javascript: void (0)" onclick = "list2 ()"> friend menu list </a>
  122. <Div>
  123. Satan's defense against Satan's Law
  124. Satan's defense against Satan's Law
  125. Satan's defense against Satan's Law
  126. Satan's defense against Satan's Law
  127. Satan's defense against Satan's Law
  128. </Div>
  129. </TD>
  130. </Tr>
  131. </Table>
  132. </Body>
  133. </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.