Jump to content

I wanted to set portfolio first item default to true.

Recommended Posts

  • Replies 4
  • Views 1.1k
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

On 2/5/2024 at 1:42 PM, square_case said:

Here is the website link:
https://www.clearchain.house

I wanted to show the portfolio first child image when someone open the website and also on hover the portfolio items it will show the different image. and make the items not clickable.

I attached the section image below.

image.thumb.png.393037a0da2b12964619b70e6773b1f8.png

this is the code that I'm using for it:

<script>
  document.addEventListener('DOMContentLoaded', function () {
    // Find the first .portfolio-hover-item and set data-active to true
    var firstPortfolioItem = document.querySelector('.portfolio-hover-item:first-child');
    if (firstPortfolioItem) {
      firstPortfolioItem.setAttribute('data-active', 'true');
    }
  });
</script>

Edited by square_case
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.