question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Make parent <li> a link, navigate and expand children upon clicking.

See original GitHub issue

Is this doable? The current behavior will ignore any <a href="www.link.com"> placed inside the parent <li>tag and just expand the list. It would be great for each list item to have the capability to have a link AND an expand button.

Issue Analytics

  • State:open
  • Created 9 years ago
  • Comments:30 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
joelioncommented, Jul 31, 2015

I would like the exact same functionality. When I click an expanding-menu, I want the menu to expand also to be redirecting to a page. In some cases, I would like to make sublinks like @adi10ain is doing. In other cases, I would like something like the following, where when I click the top-level menu item, it takes me to to the top of the page “link.html”, and the sub-menu items provide links to bookmarks elsewhere on link.html

<li>
    <a href="link.html">Parent item <span class="glyphicon arrow"></span></a>
    <ul>
        <li><a href="link.html#item2.1">item 2.1</a></li>
        <li><a href="link.html#item2.2">item 2.2</a></li>
    </ul>
</li>
3reactions
joelioncommented, Jul 31, 2015

I found a kind of work-around. How easy this is depends on what engine you’re using to create your site. I’m using Flask, so it’s pretty easy with blocks. On your main page (page1.html), you just include a link to the other page (page2.html) in the menu, with no sub-menu options. Then on the page2.html, include the sub-menus in the menu definition

page1.html

<li>
    <a href="page2.html">Parent item <span class="glyphicon arrow"></span></a>
</li>

page2.html

<li>
    <a href="page2.html">Parent item <span class="glyphicon arrow"></span></a>
    <ul>
        <li><a href="page2.html#item2.1">item 2.1</a></li>
        <li><a href="page2.html#item2.2">item 2.2</a></li>
    </ul>
</li>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Menu : expand child UL on parent LI click and disable link
Problem is that i have links to subpages on parent LI, which needs to be disabled so they don't redirect to subpage, but...
Read more >
In Praise of the Unambiguous Click Menu - CSS-Tricks
Building click menus · The element you click to show the submenu should be a <button> since it doesn't link to a page....
Read more >
How to get the child element of a parent using JavaScript
Select an element whose child element is going to be selected. Use .children property to get access of all the children of the...
Read more >
Accessible Navigation with Drupal Core's Menu System
In addition to indicating the state, you need to create a relationship between the parent <button> element and its child <ul> submenu element....
Read more >
How make top level menu item not have link, but have sub ...
1) Make the parent menu item a duplicate of the first sub-item, and change its label. For example, if the first item under...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found