Jump to content

JavaScript Help - FAQ Accordion Style

Recommended Posts

Site URL: https://www.johnbryandesign.com/services/

When you open one FAQ question, you cannot close it.

Here's my JavaScript:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
  $('.markdown-block .sqs-block-content h3').addClass('ui-closed').css('cursor','pointer');
  $('.markdown-block .sqs-block-content h3').css('cursor','pointer');
  $(".markdown-block .sqs-block-content h3").nextUntil("h3").slideToggle();
  $(".markdown-block .sqs-block-content h3").click(function() {
    $(".markdown-block .sqs-block-content h3").nextUntil("h3").slideUp();
    $(".markdown-block .sqs-block-content h3").removeClass('ui-open');
    $(".markdown-block .sqs-block-content h3").addClass('ui-closed');
    $(this).toggleClass('ui-closed ui-open');


Link to comment
  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

7 hours ago, jbryan said:

Still looking for a solution to this issue.

I suggest something like the following.

Put the following in Page Settings > Advanced > PAGE HEADER CODE INJECTION. If you are not on the business plan or above then put it in Design > Custom CSS minus the style tag.


  #page-section-5f66467c84df667bd7d0bd2f .sqs-block-markdown h3 {
    border: solid 2px;
    cursor: pointer;
    font-size: 1.4rem;
    padding: 12px;
  #page-section-5f66467c84df667bd7d0bd2f .sqs-block-markdown h3:hover {
    background-color: black;
    color: white;
  #page-section-5f66467c84df667bd7d0bd2f .sqs-block-markdown p {
    display: none;

Put the following in Settings > Advanced > Code Injection > HEADER.

<script src="//ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

Put the following in Settings > Advanced > Code Injection > FOOTER.


  $( ( ) => {
    $( '#page-section-5f66467c84df667bd7d0bd2f .sqs-block-markdown h3' ).click ( function ( ) {
      $( this )
        .nextUntil ( 'h3' )
        .slideToggle ( 'slow' );
      } );
    } );

The previous was designed specially for the site mentioned.

Replace any previous CSS or jQuery code related to the issue at hand. Make a copy of it somewhere in case you want to revert.

If you are dependent on version 1 of the jQuery library I think the Javascript can be adapted to work with it.

Let us know how it goes.

Find my contributions useful? Please like, upvote, mark my answer as best , and see my profile. Thanks for your support!

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.