Skip to content

Dropdown parent working link - add button to handle dropdown instead (Bootstrap 5) #652

Answered by crftwrk
SebGbs asked this question in Q&A
Discussion options

You must be logged in to vote

Of course, possible is everything, question is how deep you want to go. Bootstrap or the nav-walker do not support this, so you have to think a bit out-of-the-box to achieve this.

Mobile Desktop

JS

// Add link to dropdown in navbar 
$('#bootscore-navbar .nav-link.dropdown-toggle').click(function () {
  location.href = this.href;
});

// Add a .menu-toggler dropdown toggler button 
$('#bootscore-navbar .dropdown.nav-item').each(function () {
  $(this).append('<button class="menu-toggler btn btn-sm btn-primary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">Toggler</button>');
});

SCSS

.menu-toggler {
  position: absolute;
  top: 0;
  right: 0;

  @include media…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@SebGbs
Comment options

@crftwrk
Comment options

Answer selected by SebGbs
@SebGbs
Comment options

@crftwrk
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants