Two dropdown menus opening simultaneously

Recently, I encountered an issue while using a dropdown menu within a div. Even though it was functioning properly, I noticed that when I included two dropdown menus on the same page, clicking on the first one would cause both the first and second dropdowns to open simultaneously. How can I resolve this problem?

I attempted to modify the attributes such as data-toggle="dropdown", id="dropdownMenuButton", and

aria-labelledby="dropdownMenuButton"
, but unfortunately, nothing seemed to work. As a newcomer to working with bootstrap, I am seeking guidance in resolving this issue.

Below is the code for my first dropdown:

<div class="dropdown">
   <div href="#" class="form-control b-r" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="fas fa-users"></i></div>
       <div class="dropdown-menu fadeInUp" aria-labelledby="dropdownMenuButton">
       <label>Nº max</label>
             <div class="row pb-4" >
                 <div id="controls" class="text-center">
                       <div id="minus" class="btn btn-sm-click btn-info fa fa-minus pull-left"></div>
                           <input id="n_max" name="N_max" class="click select-form" readonly type="text" value="" >
                       <div id="plus" class="btn btn-sm-click btn-info fa fa-plus pull-right"></div>
                  </div>
               </div>
        </div>
  </div>

And here is the code for my second dropdown:

<div class="dropdown">
   <div href="#" class="form-control b-r" id="dropdownMenuButton_2" data-toggle="dropdown_2" aria-haspopup="true" aria-expanded="false"><i class="fas fa-users"></i></div>
       <div class="dropdown-menu fadeInUp" aria-labelledby="dropdownMenuButton_2">
       <label>Nº max</label>
             <div class="row pb-4" >
                 <div id="controls" class="text-center">
                       <div id="minus" class="btn btn-sm-click btn-info fa fa-minus pull-left"></div>
                           <input id="n_max" name="N_max" class="click select-form" readonly type="text" value="" >
                       <div id="plus" class="btn btn-sm-click btn-info fa fa-plus pull-right"></div>
                  </div>
               </div>
        </div>
  </div>

The desired outcome is for each dropdown to function independently, so that clicking on the first dropdown opens only the first dropdown, and vice versa.

I appreciate any assistance or suggestions provided. Thank you!

Answer №1

Your issue has been identified:

In the second dropdown, you have included

data-toggle="dropdown_2"

Instead, it should be

data-toggle="dropdown"

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

Simple way to extract the values from every input element within a specific <tr> tag using JQuery

Is there a way to align all input elements in a single row within my form? For example, consider the snippet of code provided below, which includes a checkbox and a text input box. I would like to retrieve the values from both of these input types and pres ...

What is the best way to stop Quasar dropdown list from moving along with the page scroll?

I am facing an issue with my code while using Quasar (Vue 3.0). The code snippet in question is: <q-select filled v-model="model" :options="options" label="Filled" /> When the drop-down menu is open and I scroll the pag ...

Design layout in Angular Material that wraps the content within it

Is there a way to achieve this specific layout with the "plus" icon positioned below the card layout? https://i.sstatic.net/W5ZRM.png I have attempted the code below: <section layout="column" style="background-color: black;"> <md-c ...

Include a label within the Highcharts Gantt chart square

I'm struggling to include a label within each box in the Gantt Diagram Highcharts, and I'm unsure how to proceed. How can I display a value within each frame? The label needs to be positioned at the center of each box, and all the data is genera ...

Decorative initials have a tendency to create spaces within the text

I have incorporated Google Fonts into my website, along with Bootstrap. Here is the code I am using: .initial { font-size: 1.5em; font-family: 'Euphoria Script', cursive; } p { font-family: 'Open Sans', sans-serif; } <html> ...

What is the reason behind the success of this location?

Curious about the functionality of this particular JavaScript code with its corresponding HTML structure: function getCityChoice() { const location = document.querySelector("form").location.value; console.log(location) } <form name="reserve" a ...

Opening Tags in Selenium for HTML

Is it possible for Selenium with XPath to properly work with HTML that is not in the form of XML, and contains open tags like <col> and <input>? I'm curious if anyone can confirm this. I ask because our automation testing team has noticed ...

Can a nodeJS script be written to automate selecting options and filling out forms in HTML?

Greetings everyone, I am new here so please excuse me if my formatting is not up to par. Currently, I am tackling a project for an internship and after some extensive research, I am stumped on how to automate certain reports in the next phase. In summary ...

Strategies for avoiding unused style tags in React components

Expanding beyond React, I'm unsure if React itself is the culprit of this issue. In a React environment with TypeScript, I utilize CSS imports in component files to have specific stylesheets for each component. I assumed these styles would only be ad ...

What causes a neighboring div to change width when a multi-line span is present?

Here is my React code: <InfoWrapper> <InfoCircle> <span>i</span> </InfoCircle> <span className="info-label"> Lorem ipsum dolor sit amet, consectetur adipiscing elit. elit. </span> </InfoWrap ...

Steps for setting a background image for a div

I am facing an issue with 3 horizontally aligned images and a background image. The problem is that when I set the background image for the aligned images, it flows over them instead of staying behind. I want the 3 aligned images to be on top of the backgr ...

Circular Graphical Representation using CSS3 styling

Check out my latest creation - a donut chart: http://jsfiddle.net/4azpfk3r/217/ I'm trying to customize the appearance of the donut chart. Is there a way to give it a red outline and have the filled score/percentage in solid red, while leaving a tran ...

A guide to revealing the value of a button or anchor tag using AngularJS

I'm working on a way to show a button or anchor tag value depending on the true or false value returned by my angular variable. Here's a snippet of my code: <a href="#" id="verify">{{userInformation.value}}</a> The userInformation.v ...

The background color of absolute divs fails to extend across the entire screen

Trying to implement a loading screen in my VueJs app using only divs. The issue is that the background color of the divs (loadingScreen) does not cover the entire screen, but only as much as the loader's height. I've attempted adding margin to th ...

Trouble arises with CSS flexbox functionality when connecting to Bootstrap 4 CDN

I'm currently utilizing CSS flexbox to design the header of my webpage by using display:flex; However, I've noticed that when I include the Bootstrap 4 CDN link in my HTML, the flexbox no longer functions as intended and the different divs within ...

What is the best way to target elements that have the contentEditable attribute set to true using CSS?

Can someone help me style table cells that have contentEditable set to "true"? I've tried various CSS selectors like td[contenteditable], td[contenteditable=true], and td[contenteditable="true"], but none seem to work. Is there a specific selector for ...

Configuring the ID of Django Form in HTML

After making modifications to the Django comment form, I realized that it doesn't have an HTML ID. How can I add an HTML ID to the entire form? The reason I need the ID is to retrieve the value of a radio select using jQuery. UPDATE: I attempted the ...

Express template failing to connect with scripts, css, and images

When using Express, I encounter difficulty in getting the css, js, and images to link up correctly when running the index.html file. The images are not showing up and the css and js files are not linking properly. <link rel="stylesheet" type="text/css" ...

Unable to conduct this search with Python using Selenium on a website

I have written a script to search for books on a webpage using Selenium: from selenium import webdriver from selenium.webdriver.common.keys import Keys import time PATH = "C:\Program Files (x86)\chromedriver.exe" driver = webdriver.Chrome(PATH) ...

Struggles with designing for multiple screen sizes

I need assistance with making my table fit inside its parent element on the locations page when the screen size is below 480px. I have a media query in my CSS that targets sizes between 250px and 780px, but for some reason, the table starts to overflow and ...