screenshots.gif

<html>

<head>
    <meta charset="utf-8">
    <title>文档标题</title>

    <style>
        #menu {
          display: none; /* 初始状态隐藏菜单 */
        }
        
    </style>

</head>

<body>
    <button onclick="toggleMenu()">展开/收起菜单</button>
    <ul id="menu" style="display: none;">
        <li>菜单项1</li>
        <li>菜单项2</li>
        <li>菜单项3</li>
    </ul>


    <script>
        function toggleMenu() {
          var menu = document.getElementById("menu");
          if (menu.style.display === "none") {
            menu.style.display = "block"; // 显示菜单
          } else {
            menu.style.display = "none"; // 隐藏菜单
          }
        }
        
    </script>


</body>
</html>