1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
| <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>下拉菜单</title> <style type="text/css"> ul li{ display: none; } </style> </head> <body> <div class="menu"> <ul> <a href="###">衬衫</a> <li>测试1</li> <li>测试2</li> <li>测试3</li> </ul> <ul> <a href="###">西装</a> <li>测试1</li> <li>测试2</li> <li>测试3</li> </ul> <ul> <a href="##">小裙子</a> <li>测试1</li> <li>测试2</li> <li>测试3</li> </ul> </div> </body> </html> <script src="js/jquery-3.5.1.js" type="text/javascript" charset="utf-8"></script> <script type="text/javascript"> $(".menu a").click(function(){ $(this).parent().find("li").slideDown().parent().siblings().find("li").slideUp(); }) </script>
|