首页 > 代码库 > 点击消失

点击消失

 1 <!doctype html> 2 <html lang="en"> 3 <head> 4     <meta charset="UTF-8"> 5     <title>Document</title> 6     <style> 7     ul 8     { 9         list-style: none;10 11     }12     #aa13     {14         width: 200px;15         height: 100px;16         background: pink;17     }18     ul #a19     {20         width: 200px;21         height: 500px;22         background: #3c3c3c;23     }24     </style>25 </head>26 <body>27     <ul>28         <li id="aa"></li>29         <li id="a"></li>30     </ul>31 32 33     <script>34     var chan1=document.getElementById(aa);35     var chan2=document.getElementById(a);36         chan1.onclick=function (){37             if (chan2.style.display=="block") {38                 chan2.style.display="none";39             }else{40                 chan2.style.display="block";41             };            42         };43 44     </script>45 </body>46 </html>

 

点击消失