Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

161
Views
Bootstrap Dropdown clickable

I am setting up a Dropdown List with Bootstrap, built up with a elements. Every List item has it own id and text = name. Then i want to add an eventListener to check if the item is clicked. If so, then i want to do something and write the chosen name in the Dropdownbutton. But the problem is, every time i click any of the different options, it only gives back the latest added name in the list.


async function setOnLoad() {
  retrieveCoordinate();

  const query = new Parse.Query("User");

  try {
    const results = await query.find();

    var json = JSON.parse(JSON.stringify(results));

    for (let i = 0; i < json.length; i++) {
      let append = document.createElement("li");
      let name = json[i].username + "" + json[i].LastName;
      append.innerHTML = "<a class='dropdown-item' id='" + name + "' href='#'>" + name + "</a>";
      dropdownmenu.append(append);
      var element = document.getElementById(name);
      element.addEventListener("click", function(){ console.log(element.id); dropdownMenuButton1.innerHTML = element.id; }); 
    } 

  } catch (error) {
    console.log(`Error: ${JSON.stringify(error)}`);
  }
}```
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!