Re: Read more/read less function is gone

Read more/read less function is gone

PernillaH
Tourist
11 0 0

 

 

Reply 1 (1)

aBox_Agency
Shopify Partner
87 9 16

Hello @PernillaH

You can use below code.

 

<div id="product-description" class="product-description">
    {{ product.description }}
</div>
<button onclick="myFunction()" class="read-button" id="read-more">Read More</button>
<button onclick="myFunction1()" class="read-button d-none" id="read-less">Read Less</button>
<script>
    function myFunction1() {
        var element = document.getElementById("product-description");
        element.classList.remove("mystyle");

        var readmore = document.getElementById("read-more");
        var readless = document.getElementById("read-less");

        readless.classList.add("d-none");
        readmore.classList.remove("d-none");
    }
    function myFunction() {
        var element = document.getElementById("product-description");
        element.classList.add("mystyle");

        var readmore = document.getElementById("read-more");
        var readless = document.getElementById("read-less");

        readless.classList.remove("d-none");
        readmore.classList.add("d-none");
    }
</script>

 

 

Thank You

Regards,
aBox Agency | Shopify Partners

Need help customizing your Shopify store? Feel free to reach out to us at Shopify Partners Directory or visit our website at aBox.Agency.

If you found this post helpful, please give it a like!