I have this vertical menu:
<li class="vertical_menu_group_item orange" id="verticalMenu"><a class="mx-3" >Menu item</a>
<ul style="display:none" class="submenus">
<li><a href="">Sub menu item 1</a></li>
<li><a href="">Sub menu item 2</a></li>
</ul>
</li>
And as you can see I have set the display:none for the class submenus and then within this Javascript code I tried to show the sub menu items, when user click on the menu item:
$(document).on('click','#verticalMenu',function(){
let sbm = document.querySelector(".submenus");
sbm.style.display = "block";
});
But now this thing does not work out and not shows the sub menu items.
However, I have made sure that the onlick event runs successfully.
I also tried showing the sub menu items like this:
sbm.toggle();
But it says: toggle is not a function
So what's going wrong here? How can I properly hide/show this .submneus class when clicking on the link with id of verticalMenu?