From Accordion in the jQuery UI docs.

<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>

<script>
    $(function () {
        $("#accordion").accordion();
    });

</script>

Target an element like:

<div id="accordion">
  <h3>Section 1</h3>
  <div>
    <p>
      Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam.
    </p>
  </div>
  
  <h3>Section 2</h3>
  <div>
    <p>
      Vivamus nisi metus, molestie vel, gravida in, condimentum.
    </p>
  </div>
</div>