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

97
Views
¿Cómo puedo usar alternar y la función que elimina la clase del elemento anterior juntos solo usando JavaScript que he intentado de diferentes maneras?

- Primera Vía -

Aquí no puedo eliminar los elementos anteriores y agregar la clase para el nuevo

 linksBtnArr.forEach((item, index) => { item.addEventListener("click", () => { arrowArr[index].classList.toggle("active"); if (arrowArr[index].classList.contains("active")) { menuArr[index].style.display = "block"; } else { menuArr[index].style.display = "none"; } }); });

- Segunda Vía -

Aquí puedo eliminar el elemento anterior, pero no puedo usar Toggle para eliminar el formulario de clase El mismo elemento en el que hice clic nuevamente

 linksBtnArr.forEach((link, i) => { link.addEventListener("click", () => { removeActiveClasses(); arrowArr[i].classList.add("active"); }); }); // Remove The previous Menu function removeActiveClasses() { arrowArr.forEach((arrow) => { arrow.classList.remove("active"); }); }
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Por aquí

 linksBtnArr.forEach( (lk,_,All_lk) => { lk.onclick =_=> { if (lk.classList.toggle('active')) All_lk.forEach( lx=> lx.classList.toggle('active', lk===lx) ) } })
about 4 years ago · Juan Pablo Isaza Report

0

Mire los enlaces de UL ¡Eso es lo que estoy tratando de hacer! https://mohmostafa-web.github.io/blogr-landing-page-frontend-mentor

about 4 years ago · Juan Pablo Isaza Report
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!