Need Help Setting First Collapsible Tab to Open by Default

Solved

Need Help Setting First Collapsible Tab to Open by Default

technase
Shopify Partner
219 2 53

Hi

I need assistance with one of the collapsible tabs on the product page. Currently, all the tabs are closed by default, but I would like the first tab to be open by default.

 

Could someone help me with this?

Link: https://testingstoresandthemes.myshopify.com/products/780ml-shaker
Storefront password: lock

 

attaching photo for reference 

screencapture-testingstoresandthemes-myshopify-products-780ml-shaker-2024-10-10-15_25_23.png

technase
Accepted Solution (1)

Moeed
Shopify Partner
7334 1989 2424

This is an accepted solution.

Hey @technase 

Follow these Steps:

1) Go to Online Store
2) Edit Code
3) Find theme.liquid file

4) Add the following code in the bottom of the file above </body> tag

<script>
    document.addEventListener("DOMContentLoaded", function() {
        var accordion = document.getElementById("Details-collapsible-row-1-template--18554506641653__main");
        if (accordion) {
            accordion.setAttribute("open", "");
        }
    });
</script>

RESULT:

Moeed_0-1728556724956.png

 

If I managed to help you then, don't forget to Like it and Mark it as Solution!

 

Best Regards,
Moeed

- Need a Shopify Specialist? Chat on WhatsApp

- Get a quick Shopify quote – Click here!

- Custom Design | Advanced Coding | Store Modifications


View solution in original post

Replies 2 (2)

Moeed
Shopify Partner
7334 1989 2424

This is an accepted solution.

Hey @technase 

Follow these Steps:

1) Go to Online Store
2) Edit Code
3) Find theme.liquid file

4) Add the following code in the bottom of the file above </body> tag

<script>
    document.addEventListener("DOMContentLoaded", function() {
        var accordion = document.getElementById("Details-collapsible-row-1-template--18554506641653__main");
        if (accordion) {
            accordion.setAttribute("open", "");
        }
    });
</script>

RESULT:

Moeed_0-1728556724956.png

 

If I managed to help you then, don't forget to Like it and Mark it as Solution!

 

Best Regards,
Moeed

- Need a Shopify Specialist? Chat on WhatsApp

- Get a quick Shopify quote – Click here!

- Custom Design | Advanced Coding | Store Modifications


Charming_Beads
Excursionist
28 0 7

Hi Moeed,

 

I am trying to achieve the same thing on my site.  Would your code be transferable to my liquid file or does it need to be custom code please?

 

www.charming-beads.co.uk

 

Many thanks,

Paul