Jump to content

Hyperlink in Accordion Title

Recommended Posts

Posted

I'm looking to use an accordion block as a menu on my homepage. However, I only want certain sections to expand, while using just the title of the other sections — what I'm looking to do is create a hyperlink for those non-expandable section titles so they connect to pages on the site. 

This is a rough example: https://toddmartinfilms.com

  • 1 month later...
Posted

I am also trying to do this. 

I've disabled the accordion description so only titles show, and I want to turn the title into a clickable link. Is this possible?

 

@tuanphan you might know! You're ace at this stuff. 

Posted
On 3/4/2024 at 2:10 PM, forgooddigital said:

I am also trying to do this. 

I've disabled the accordion description so only titles show, and I want to turn the title into a clickable link. Is this possible?

 

@tuanphan you might know! You're ace at this stuff. 

First, change accordion item, from this

your current title accordion

to this

<a href="https://google.com">your current title accordion</a>

Next, add this code to Website > Website Tools > Code Injection > Footer

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
  $("span.accordion-item__title").each(function(){
    $(this).html($(this).text());
  });
});
</script>

 

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

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.