How can I create an interactive navigation menu with CSS and JavaScript?

Seeking guidance for a dynamic tennis club menu using only CSS and JavaScript. Example:

<ul id="navItems">
  <li onclick="toggleSection('main')">Dashboard</li>
  <li onclick="toggleSection('overview')">Club Overview</li>
  <ul id="overviewMenu" style="display:none;">
    <li>Team</li>
    <li>Rates</li>
    <li>Events</li>
  </ul>
</ul>
<script>
function toggleSection(section) {
  var submenu = document.getElementById(section === 'overview' ? 'overviewMenu' : '');
  if (submenu) submenu.style.display = submenu.style.display === 'none' ? 'block' : 'none';
}
</script>

u might try sticking with class toggel methods over inline styles. using event delegation could work better incase of dynamic insertions, and it makes managing states easier. also be careful with naming ids consistently to avoid unexpected bugs

I have found that separating the JavaScript from the HTML markup greatly improves the maintainability of the navigation menu. Instead of using inline event handlers, I prefer adding event listeners in the script, which results in a cleaner separation of concerns. In my experience, this not only makes debugging easier but also ensures the code is scalable for future changes. Besides toggling classes for state changes, using CSS transitions can enhance the user experience by providing a smooth visual effect during the menu expansion and collapse processes.