How to create accordion
Accordion script is created in two steps: add the script to the page header, and then create the content in a markdown block.
Add the script to the page
1 - In the left-hand navigation, find the page you want to add the accordion to. Click the gear icon to edit the page.
2 - Click on the Advanced tab. Copy the script from below into the Code Injection window. Click save.
<script>
$(document).ready(function(){
$('.markdown-block .sqs-block-content h4').css('cursor','pointer');
$(".markdown-block .sqs-block-content h4").nextUntil("h4").slideToggle();
$(".markdown-block .sqs-block-content h4").click(function() {$(this).nextUntil("h4").slideToggle();});
});
</script>
Create content in a markdown block
After the script has been added, it uses information in a markdown block to determine what is part of the accordion.
1 - Create a markdown block
2 - Create the first heading by typing “####” (4 hashtags means heading level 4) followed by a space, and then your heading. We use the “+” to cue the reader that the heading is an accordion, but it’s not strictly necessary. e.g.
#### + First Accordion heading
3 - Hit enter to go to the next line and then write all the content that will be below the accordion. Hit enter a couple of times after the content to create a space before the next heading.
4 - Repeat steps 2-3 for as many entries you wish to be in the accordion
5 - Create a new text block (or any content block) below the accordion to continue adding other content.
Example
Inspect the example below by editing this page and looking at the markup block.
+ Lorem ipsum dolor
sit amet, consectetur adipiscing elit. Sed id sollicitudin erat. Fusce tristique turpis ac feugiat rhoncus. Vestibulum aliquam, elit id placerat pellentesque, dolor tellus aliquet dui, et tempor tortor justo tempus nulla. Nam tristique nulla lobortis, interdum tortor auctor, blandit ex. Mauris bibendum ullamcorper commodo. Nulla non sodales lorem.
+ Sed in libero
quis tellus tempor euismod. Integer sem sem, suscipit id enim in, lacinia interdum dui. Donec nunc enim, rutrum sed gravida sit amet, tincidunt vel ante. Duis feugiat nulla lacus, non tincidunt turpis feugiat non. Morbi eu urna ut est pulvinar ultrices eget et risus.
+ Morbi at justo felis.
In ultrices molestie elit, at aliquet tortor dapibus a. Cras sem ex, posuere ut est laoreet, consectetur sollicitudin nisi. Maecenas in porttitor nisi. Donec mollis turpis quis magna gravida, nec imperdiet lectus facilisis. Fusce vel libero nisl. Quisque vehicula eu ex sed posuere. Morbi velit ipsum, luctus et dolor eget, bibendum dignissim quam. Nulla tristique dui odio, vitae pulvinar arcu euismod sed. Morbi sed mollis turpis. Duis sed nulla commodo, hendrerit est in, imperdiet tellus. Sed fermentum ullamcorper lorem id dignissim. Pellentesque neque lorem, tempus vel cursus semper, consequat vel neque. Duis venenatis augue quis vulputate pellentesque.