Rosemarie Posted May 30, 2021 Share Posted May 30, 2021 (edited) Hello squarespace community, I have made a page with a +- toggle foldout option. After the main 'head subject +' I would like to make another list with new +- options that are not visible when the head section is not opened. Underneath how I would like it to look / work: Head Subject + (always visible) After opening: Head Subject - Secondary Subject + (Only visible when head subject is open) Secondary Subject + (Only visible when head subject is open) After opening secondary subject Head Subject - Secondary Subject - (Only visible when head subject is open) Information about the secondary subject Secondary Subject + (Only visible when head subject is open) Does anyone have an idea if this is possible? And how? My current page injection code: <script> $(document).ready(function() { $('.markdown-block .sqs-block-content h3, h4').addClass('ui-closed').css('cursor', 'pointer'); $('.markdown-block .sqs-block-content h3,h4').nextUntil('h3,h4').slideToggle(); $('.markdown-block .sqs-block-content h3,h4').click(function() { if ($(this).nextUntil('h3,h4').is(':hidden')) { $('.markdown-block .sqs-block-content h3,h4').nextUntil('h3,h4').slideUp(); $(".markdown-block .sqs-block-content h3,h4").removeClass('ui-open'); $(".markdown-block .sqs-block-content h3,h4").addClass('ui-closed'); $(this).nextUntil('h3,h4').slideDown(); $(this).toggleClass('ui-closed ui-open');} else { $(this).nextUntil('h3,h4').slideUp(); $(this).toggleClass('ui-closed ui-open');} }); }); </script> Edited May 30, 2021 by Rosemarie typo Polux 1 Link to comment
tuanphan Posted June 1, 2021 Share Posted June 1, 2021 I think above won't work in this case. Try accordion plugin or choose a free code here & then share url, we will tweak it to work with Squarespace. https://codepen.io/brenden/pen/Kwbpyj https://codepen.io/hedayethm/pen/pqLWdL Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message How to: Setup Password & Share url - Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care Link to comment
Amaya_SQSP Posted February 23, 2022 Share Posted February 23, 2022 Hi @Rosemarie, I see that you were looking for a solution to create an accordion on your site and may have used some custom code to try to create it but you experienced some issues. I'm happy to say that should you want to add an accordion to your site without additional code, you can do so using the accordion block! We have some information about the possibilities and customizations of the accordion block in our guide "Accordion blocks" should you want to take a look. Happy site building! Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment