Jump to content

Recommended Posts

Does anyone know how I can target the last visible tag on a summary item?

<script>
$(function () { 
$('.summary-metadata-item--tags > a:visible:last').addClass('mk-last-visible');
});  
</script>

I tried using the above script. It works in code-pen but not when I add it to code injection header in Squarespace.

Can anyone tell me why this isn't working and how I can fix it?

 

I have CSS already set up to target the summary block on the Healthcare Practices tab here:

website: https://beehyve.squarespace.com/adhd-support

 

Link to comment
  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Hi @melaniejaane!

I found in the jQuery documentation that it says that the `:last` selector selects the last matched element. I think that means the last instance that matches the selector, and thus only one item. 

I was going to recommend the `last-child` selector, but just in case the `last-child` is hidden, here is a better solution. This selects the last one for the tag section of each summary item (actually the last tag of each tag section).

<script>
$(function () { 
    $('.summary-metadata-item--tags').each(function() {
        $(this).children('a:visible:last').addClass('mk-last-visible')   
    })
}); 
</script>

Hope this helps!

Daniel Rodrigues | Excito LLC
Squarespace Web Design for Photographers & Creatives
🌐 https://www.excitollc.com/ | ✉ Contact Me: daniel@excitollc.com
💡 Squarespace Enthusiast | 📖 Squarespace Design Blog for Photographers
🤝 Always happy to help and collaborate! Connect with me on LinkedIn.

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.