Jump to content

tsl_hscho

Member
  • Posts

    8
  • Joined

  • Last visited

Reputation Activity

  1. Like
    tsl_hscho reacted to creedon in How do I make a collapsible page section?   
    Possible I'd say yes.
    One way to do it might be to have a page section with the first block a text block with your toggle text or symbol in it.
    Then follow with whatever other block you want.
    Then your CSS would hide all but the first block of the page section.
    Then you would have some code like the following.
    <script> $( '.page-section:nth-of-type( 1 ) .html-block:first' ).click ( function ( ) {         $( this )                .nextUntil ( '.page-section' )                  .slideToggle ( 'slow' );                } );        </script> This is not a fully fleshed out piece of code. It is just one possible starting point.
    If you were going to toggle all page sections then you wouldn't need the nth. If you needed only some then add more. Something like...
    const selector = '.page-section:nth-of-type( 1 ) .html-block:first, ' + '.page-section:nth-of-type( 3 ) .html-block:first'; $( selector ).click... I tested this code out here and it seemed to work well.


    Let us know how it goes.
×
×
  • 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.