How to make collapsible row close after another one opens

Solved

How to make collapsible row close after another one opens

undercoverfresh
Excursionist
138 0 19

I'm looking to make the collapsible row in the (product information) page close after someone opens up another one for desktop and mobile on dawn theme 

 

 

Accepted Solution (1)

WebDeskSolution
Shopify Partner
203 46 55

This is an accepted solution.

Hello @undercoverfresh 

 

Please follow the steps below after logging into the Shopify admin:

 

  • Go to your Shopify Admin panel.

 

 

  • Click on Online Store > Themes.
  • Find the theme you want to edit and then click Actions > Edit code.

 

<script>
      window.addEventListener("load", function () {
          document.querySelectorAll("details").forEach((details) => {
              details.addEventListener("click", function () {
                  if (this.open) {
                      document.querySelectorAll("details").forEach((other) => {
                          if (other !== this) {
                              other.removeAttribute("open");
                          }
                      });
                  }
              });
              details.addEventListener("toggle", function () {
                  if (this.open) {
                      document.querySelectorAll("details").forEach((other) => {
                          if (other !== this) {
                              other.removeAttribute("open");
                          }
                      });
                  }
              });
          });
      });
    </script>

 

 

Please hit Like and Mark it as a Solution if you find our reply helpful.

 

Thank You,


WebDesk Solution Support Team
Get a Free Quote | Email | Shopify Partner | Shopify Development Agency | Call: 877.536.3789


Canada: 150 King St W. STE 200, Toronto, ON M5H 1J9

 | USA: 98 Cutter Mill Rd. STE 466, Great Neck, NY 11021

View solution in original post

Reply 1 (1)

WebDeskSolution
Shopify Partner
203 46 55

This is an accepted solution.

Hello @undercoverfresh 

 

Please follow the steps below after logging into the Shopify admin:

 

  • Go to your Shopify Admin panel.

 

 

  • Click on Online Store > Themes.
  • Find the theme you want to edit and then click Actions > Edit code.

 

<script>
      window.addEventListener("load", function () {
          document.querySelectorAll("details").forEach((details) => {
              details.addEventListener("click", function () {
                  if (this.open) {
                      document.querySelectorAll("details").forEach((other) => {
                          if (other !== this) {
                              other.removeAttribute("open");
                          }
                      });
                  }
              });
              details.addEventListener("toggle", function () {
                  if (this.open) {
                      document.querySelectorAll("details").forEach((other) => {
                          if (other !== this) {
                              other.removeAttribute("open");
                          }
                      });
                  }
              });
          });
      });
    </script>

 

 

Please hit Like and Mark it as a Solution if you find our reply helpful.

 

Thank You,


WebDesk Solution Support Team
Get a Free Quote | Email | Shopify Partner | Shopify Development Agency | Call: 877.536.3789


Canada: 150 King St W. STE 200, Toronto, ON M5H 1J9

 | USA: 98 Cutter Mill Rd. STE 466, Great Neck, NY 11021