Jump to content

Markdown - Only show one dropdown at a time

Recommended Posts

Site URL: https://www.nanoesclab.com/publications

I have a markdown containing a large amount of items. They are categorised by year, which each collapsible item labelled as a year.

I have the following script in my page settings, which works fine. 

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<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();});
});
$(document).ready(function(){
$('.markdown-block .sqs-block-content h2').click(function()
{$(this).toggleClass('plus-minus');});
});
</script>

However, I'd like it to only have one year open at a time. So when a new year is clicked the previously open one will automatically close.

Any ideas??

Link to comment
  • Replies 1
  • Views 414
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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.