Jump to content

Markdow- Dropdown-H2 heading: need to close previous H2, when opening new H2

Recommended Posts

Posted

Can you help me setup up my mardkdown dropdown H2 to open one at a time, and close the previous H2 heading when opening a new H2 heading? Is it possible to do through CSS codes or need to modify HTML code:

my  current header injection code in Squarespace webpage is:

<script>
$(document).ready(function(){
$('.markdown-block .sqs-block-content h2').css('cursor','pointer');
$(".markdown-block .sqs-block-content h2").nextUntil("h2").slideToggle();
$(".markdown-block .sqs-block-content h2").click(function() {$(this).nextUntil("h2").slideToggle();});
});
</script>
 

What should be changed in this code to make this change?

 

 

  • Replies 1
  • Views 1.2k
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Posted

Hey, you can try the code from here: https://www.adlyticmarketing.com/blog/squarespace-creating-an-accordion-style-faq-section

Also, Squarespace has an accordion block now, so see if that'll suit your needs as well.

If an answer I provide helps you, please mark it as the answer so others can easily access it as well.

I'm a Squarespace Authorized TrainerSquarespace Expert, and Circle Member and I've been helping my clients as well as those here in the forum and in various Squarespace groups with custom coding and support for Squarespace websites. I would love to help you in any way I can.

Squarespace PluginsBook Live Help | Squarespace Video Tutorials | Buy Me a Coffee

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.