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

116
Views
Open accordion panel with an anchor link

I need help to make an anchor link open the corresponding accordion panel within an accordion. So far I've added the anchor link so that the page scrolls down to the panel, but I can't get it to open.

Link structure:

<a href="#CO">link text</a>

Accordion structure:

<button class="accordion" id="CO">button header</button>
<div class="panel">
<p>text</p>
</div>

JS structure:

<script>
                
        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("active");

    /* 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";
    }
  });
}
</script>

thank you!!

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

0

I would actually suggest trying to take a look into the details HTML tag.

https://www.w3schools.com/tags/tag_details.asp

It most likely has everything you need. All it needs is a bit of styling and you're good to go. Then you don't need to have additional JavaScript for toggling the visibility of the content.

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!