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

220
Views
Click event doesn't work in the first click, why?

I am trying to make an accordion menu. I am comparing the height property to open and close the menu. But in the first click it doesn't work, it works well after the second, third click. To me, my algorithm made sense. But often I get results that I didn't expect.

let portfolio_button = document.getElementById('portfolio--button');
let portfolio_menu = document.getElementById('portfolio--menu');
let i = 0;
let mobile_menu = document.getElementById('mobile--menu');
let mobile_menu_icon = document.getElementById('mobile--menu--icon');





function portfolioMenu(){
   if(portfolio_menu.style.height === "0px"){
       portfolio_menu.style.height = "100px";
       mobile_menu.style.height = "370px";
   }
   else{
       portfolio_menu.style.height = 0;
       mobile_menu.style.height = "270px";
   }
}

function openMobileMenu() {
   if (mobile_menu.style.height === "
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!