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

187
Views
onclick sometimes trigger once and twice for it to activate in codeigniter

I had this kind of scenario that I wanted for it to happen, this is when I click the button, there would be a drop down list that will appear, and if i click outside of it, it would collapse automatically.

My main problem is that, that button after clicking once, it had to be clicked twice for the dropdown list to appear.

let settingsmenu = document.querySelector(".settings-menu");
function settingsMenuToggle() {
  document.addEventListener('click', function() {
    settingsmenu.classList.toggle("settings-menu-height");
  })
}
#coverphoto, #profilephoto, .userpic{
    height: 100%;
    width: 100%;
}
<ul style="right:10px; top:0px; margin-top:4px; margin-bottom: 5px;" class="navbar-nav ml-auto position-fixed end-50 ">
  <li style="position:relative;" class="nav-item dropdown">
    <a class="nav-link " role="button" onclick="settingsMenuToggle()">
      <img src="<?php echo base_url();?>assets/image/user.png" width="40" height="40" class="userpic rounded-circle position-absolute">
    </a>
    <div class="dropdown-menu">
      <a href="<?php echo base_url();?>pages/view/setting">Settings</a>
      <a href="#">Customization</a>
      <a href="<?php echo base_url();?>pages/view/logout">Logout</a>
    </div>
  </li>
</ul>

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!