1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- <style>
- *{
- margin: 0;
- padding: 0;
- }
- ul{
- list-style: none;
- }
- h2{
- width: 300px;
- height: 50px;
- background: #000;
- color: white;
- }
- ul{
- display: none;
- }
- </style>
- </head>
- <body>
- <div id="container">
- <h2>管理区</h2>
- <ul>
- <li>111</li>
- <li>111</li>
- <li>111</li>
- </ul>
- <h2>交流区</h2>
- <ul>
- <li>222</li>
- <li>222</li>
- <li>222</li>
- </ul>
- </div>
- <script>
- var h2 = document.getElementsByTagName('h2')
- for(var i=0;i<h2.length;i++){
- h2[i].onclick = function(){
- var ul1 = this.nextElementSibling
- if(ul1.style.display == 'block'){
- ul1.style.display = 'none'
- } else{
- ul1.style.display = 'block'
- }
- }
- }
- </script>
- </body>
- </html>
|