How to colapse open submenu items when another item is clicked?

Hi. I have a mobile menu on my website that has a few sub-menu items. When i click an item that has sub-items, it expands, as expected. But, if i click another item, the previous one remains expanded. I would like it to auto-colapse. How can i accomplish this? Velo code? any help is very much appreciated.

To make the button toggle the box state (expand it if collapsed or collapse if expanded):

$w.onReady(() => {
   $w('#toggleBtn').onClick(() =>  $w('#box').collapsed ?  $w('#box').expand() :  $w('#box').collapse());
})

I tried this, but “toggleBtn” and “box” don’t seem to be valid classes.
How do i even even find or set the classes of these items? I can’t seem to be able to dig deeper into a menu to set the classes.

@J.D any insights on this?

These are element ids. You need to edit your element id from the inspector panel. Here it is:

Change your button id to “toggleBtn” and your box id to “box”.

Thanks. But i dont seem to be able to edit the elements in a mobile menu from the inspector panel.
My guess is that i dont have wix studio (or editor x)… is there a way to edit this in the classic wix editor? All i have is the dev panel, and it doesn’t allow me to dig deeper in the menu.

If you are trying yo change the element id it doesn’t matter if it’s mobile or not element ids are always same.

If you trying to change the visual things for mobile then there are some limitations on classic editor as I remember. Haven’t used classic editor for a long time so not sure.

i have same issues with my vertical menu? Any solutions?

any updates? please ?