The functionality of one button triggering the opening of two dropdown menus simultaneously is being successfully implemented

My issue is that I have created two different dropdowns, but they both open the same dropdown menu.

Here is my code;

<div class="d-flex">

          <button class="btn btn-icon btn-group-nav shadow-sm btn-secondary dropdown-toggle" type="button" data-toggle="dropdown" data-offset="0 8" aria-haspopup="true" aria-expanded="false">
            <span class="btn-inner--icon"><i class="far fa-sliders-h"></i></span>
            <span class="btn-inner--text d-none d-md-inline-block">Sort by</span>
          </button>
          <div class="dropdown-menu dropdown-menu-left dropdown-menu-arrow">
            <a class="dropdown-item" href="">Price</a>
            <a class="dropdown-item" href="">Amount</a>
            <a class="dropdown-item" href="">Number</a>
          </div>

          <button class="btn btn-icon btn-group-nav shadow-sm btn-secondary ml-auto dropdown-toggle" type="button" data-toggle="dropdown" data-offset="0 8" aria-haspopup="true" aria-expanded="false">
            <span class="btn-inner--icon"><i class="far fa-user"></i></span>
            <span class="btn-inner--text d-none d-md-inline-block">User</span>
          </button>
          <div class="dropdown-menu dropdown-menu-right dropdown-menu-arrow">
            <a class="dropdown-item" href="account-settings.html">Settings</a>
            <a class="dropdown-item" href="account-billing.html">Billing</a>
            <a class="dropdown-item" href="account-notifications.html">Notifications</a>
          </div>

</div>

What steps should I take to resolve this issue?

Answer №1

According to the reference material, it is advised to:

Enclose the toggle for the dropdown (which could be a button or link) and the dropdown menu within a .dropdown container

<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" />
<div class="d-flex">
   <div class="dropdown">
      <button class="btn btn-icon btn-group-nav shadow-sm btn-secondary dropdown-toggle" type="button" data-toggle="dropdown" data-offset="0 8" aria-haspopup="true" aria-expanded="false">
      <span class="btn-inner--icon"><i class="far fa-sliders-h"></i></span>
      <span class="btn-inner--text d-none d-md-inline-block">Sort by</span>
      </button>
      <div class="dropdown-menu dropdown-menu-left dropdown-menu-arrow">
         <a class="dropdown-item" href="">Price</a>
         <a class="dropdown-item" href="">Amount</a>
         <a class="dropdown-item" href="">Number</a>
      </div>
   </div>
   <div class="dropdown">
      <button class="btn btn-icon btn-group-nav shadow-sm btn-secondary ml-auto dropdown-toggle" type="button" data-toggle="dropdown" data-offset="0 8" aria-haspopup="true" aria-expanded="false">
      <span class="btn-inner--icon"><i class="far fa-user"></i></span>
      <span class="btn-inner--text d-none d-md-inline-block">User</span>
      </button>
      <div class="dropdown-menu dropdown-menu-right dropdown-menu-arrow">
         <a class="dropdown-item" href="account-settings.html">Settings</a>
         <a class="dropdown-item" href="account-billing.html">Billing</a>
         <a class="dropdown-item" href="account-notifications.html">Notifications</a>
      </div>
   </div>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

jquery dialog content vanishing upon second opening

My jQuery code is set up to display a dialog when a button is clicked. The issue I'm experiencing is that after closing the dialog and reopening it, the text area within the dialog appears empty with only three buttons visible. However, upon subsequen ...

The drop-down menu remains visible even after clicking outside of it

I've written a script that works when clicked, but it doesn't hide when clicked outside of it. $(document).ready(function() { //Translate(); //caling Language Translater function $("#translate_image").attr('href', base_url) ...

What is the way to modify the standard request for an "@" in the email address?

Although I've successfully changed the error message for when the user forgets to type in their email, I'm now wondering how to modify it when the user enters their email in the wrong format. Below is the code I've written in the style of B ...

When a user hovers over the image, a button is revealed

I have a test page on my website: If you'd like to check it out, feel free to visit: I am trying to create a feature where when you hover over an image, a black button with text and links will appear. When you move your mouse away from the image, ...

Unraveling the Mystery of React Event Bubbling: Locating the Desired

I am working with a <ul> Component that wraps several <li> Components. To streamline my code, I would like to avoid adding an individual onClick handler to each li and instead utilize a single handler on the parent ul element to capture the bub ...

What steps can I take to address the problem in iOS 17 where sound is coming from the earpiece instead of the speaker during camera activation?

I have a Progressive Web App where I use the getUserMedia() API to access the camera and HTML audio tags for handling media content. However, ever since updating to iOS 17, I've faced an issue where audio plays through the earpiece instead of the medi ...

Filtering incoming data from a Firestore database: A step-by-step guide

I'm facing a challenge while trying to incorporate this filtering mechanism into my code. FILTERING An issue arises when I attempt to implement the following lines of code: function search(text: string, pipe: PipeTransform): Country[] { return CO ...

Refresh Entity with Real-Time Data on Cesium

I have been attempting to showcase an entity moving within Cesium through the use of live/dynamic data. After trying various techniques and consulting past forums, particularly those from 2015-2016, I am still struggling to make it work. Despite my effort ...

I am struggling to display the data fetched by Next.js on the page

I am struggling to display the data from the first file in my tanstack table or as a string within the HTML, even though I can see it in a console.log when grabbed by axios. The tanstack table worked fine with hardcoded data. In the console image provided, ...

How come my ajax function is not processing when the form is submitted?

Having an issue with validating a form where I need to check if a username is available before submission. Although all functions, including the PHP script for checking the username, are working properly, I'm unable to prevent the form from submitting ...

What is the best way to eliminate a particular element from an array produced using the .map() function in

I am experiencing an issue with my EventCell.tsx component. When a user clicks on the component, an event is created by adding an element to the components state. Subsequently, a list of Event.tsx components is rendered using the .map() method. The problem ...

Changing the time zone of a browser using JavaScript or jQuery

After researching numerous discussions on the topic, it appears that changing the browser's timezone programmatically is not possible. Although the moment-timezone.js library allows us to set timezone for its objects, it does not affect the browser&ap ...

The AWS Lambda function utilizing Puppeteer is encountering an issue when trying to switch to a new

My Puppeteer project running in AWS Lambda stopped working since yesterday. I made a small code change, but it keeps getting stuck at the browser's newPage method, even after reverting my changes. I am utilizing the lambda starter kit project from: h ...

accurate JSONP reply

Currently, I am experimenting with JSONP locally to receive a correct response and pass it into my callback function jsonp_callback. I am referencing code from: How do I set up JSONP? header('content-type: application/json; charset=utf-8'); $dat ...

I'm receiving the error message "Fatal error: Call to a member function query() on a non-object," what could be causing this issue?

Need help with fixing an error on my private server realmeye. The error message I'm receiving is: Fatal error: Call to a member function query() on a non-object in /home/noxus/public_html/realmeye/index.php on line 112 =========================== ...

JS glitch leading to oversized window dimensions - Issue with dropdown menu

I recently integrated a dropdown into my website using Foundation CSS. To see the dropdown in action, you can login with the credentials provided (username: stackoverflow password: testtest) on . However, I noticed that when logged in, the page on the rig ...

Is your Jquery validation malfunctioning?

I am currently facing a challenge with required validation on an asp.net page. In order to validate the inputs, I have implemented multiple controls which can be hidden or displayed based on certain conditions. These controls include checkboxlists, dropdow ...

Discover the power of lodash's .groupBy method as you learn how to efficiently group objects within another

Utilizing lodash's _.groupBy function, I have generated the following data: { "Generic Drugs":[ { itemDes: "Dulcolax", itemGeneric: "Bisacodyl", pr ...

Preserving chosen options in a dropdown menu using PHP and HTML

I'm facing an issue with my code where the selected values in a dropdown menu revert back to default every time the page refreshes. How can I ensure that the selected values remain unchanged? Unfortunately, I am unable to utilize AJAX as per the user ...

Best Practices for Converting TypeScript to JavaScript

What is the recommended approach to converting this JavaScript code into TypeScript? JAVASCRIPT: function MyClass() { var self = this, var1 = "abc", var2 = "xyz"; // Public self.method1 = function () { return "somethin ...