Expanding the mobile menu to show sub-menu items by default

Posted in: Newspaper
Post count: 17

Hi,

If we wanted to have any sub menu items showing by default in the mobile view (so the

    list appears expanded), what would be the best / cleanest way of achieving this in a child theme?

    Thanks!

    P.S it would be nice if this could be an option within Theme Panel…for smaller sites it would be great.

Post count: 17

Hi – Just to ensure you fully understand this, when the mobile menu is expanded to show the sub-menu items, the parent menu item has “td-sub-menu-open” added to the classes.

So, by default, in the mobile view we want

Parent menu-item 1
– Sub-menu item a
– Sub-menu item b
– Sub-menu item c
Parent menu-item 2
– Sub-menu item d
– Sub-menu item e
– Sub-menu item f

etc

Thanks!

Post count: 35449

Hi,

In order to achieve that the easiest way would be with js
var submenius = document.getElementsByClassName("menu-item");
for(var i = 0; i < submenius.length; i++)
{
submenius[i].className += " td-sub-menu-open";
}

https://www.screencast.com/t/vPms4Wg1Qfd
Hope this will help you.

Thank you for your understanding.

Viewing 3 posts - 1 through 3 (of 3 total)
The forum ‘Newspaper’ is closed to new topics and replies.