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

180
Views
Cómo hacer un acordeón con HTML y JS

Quiero que se despliegue un acordeón cuando un usuario haga clic en el signo mayor que.

ingrese la descripción de la imagen aquí

 <div class="row"> <div class="col-2"> <p>DEP-08B827E791<button class="accordion"><i class="fa-solid fa-greater-than fa ps-1"></i></button></p> </div> <div class="col-3"> <P>Omodeko Divine</P> </div> <div class="col-2"> <p>EE</p> </div> <div class="col-3"> <p>[ETHIOPE EAST]</p> <P>DELSU HEALTH CENTER ABRAKA</P> </div> <div class="col-2"> <button class="btn btn-primary">GENERATE ID</button> </div> <div class="panel" onclick="document.getElementByclassname(panel).style.display='none'"> <p>No, but there must be adequate evidence that would help to support your claim.</p> </div> </div>

este es el javascript

 var acc = document.getElementsByClassName("accordion"); var i; for (i = 0; i < acc.length; i++) { acc[i].addEventListener("click", function() { /* Toggle between adding and removing the "active" class, to highlight the button that controls the panel */ this.classList.toggle("activee"); /* Toggle between hiding and showing the active panel */ var panel = this.nextElementSibling; if (panel.style.display === "block") { panel.style.display = "none"; } else { panel.style.display = "block"; }});}

Al hacer clic en el signo mayor que, se supone que el .panel se desplegará.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

  1. Agregue el evento onclick al ícono mayor que
  2. A continuación, agregue id a .panel div
  3. A continuación, en el script, escriba la lógica para ocultar y mostrar, consulte el fragmento de código a continuación

 function showDropDown(){ const targetDiv = document.getElementById("panelDivId"); if (targetDiv.style.display !== "none") { targetDiv.style.display = "none"; } else { targetDiv.style.display = "block"; } }
 <div class="row"> <div class="col-2"> <p>DEP-08B827E791<button class="accordion"><i class="fa-solid fa-greater-than fa ps-1" onclick="showDropDown()">greaterThanIcon</i></button></p> </div> <div class="col-3"> <P>Omodeko Divine</P> </div> <div class="col-2"> <p>EE</p> </div> <div class="col-3"> <p>[ETHIOPE EAST]</p> <P>DELSU HEALTH CENTER ABRAKA</P> </div> <div class="col-2"> <button class="btn btn-primary">GENERATE ID</button> </div> <div class="panel" id="panelDivId" onclick="document.getElementByclassname(panel).style.display='none'"> <p>No, but there must be adequate evidence that would help to support your claim.</p> </div> </div>

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!