Jump to content

Hyperlink in Accordion Title

Recommended Posts

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

Link to comment
  • 1 month later...
  • Replies 2
  • Views 1.6k
  • Created
  • Last Reply

Top Posters In This Topic

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!)

Link to comment

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.