I Have created a More/Less toggle button for which I have used https://jadepuma.com/blogs/blog/more-less-toggles-for-shopify-descriptions.
It works, but want to create a transition. When click read more button, it slowly opens the rest of the content. And click read less it slowly shuts.
This is what I am after, when button is toggled, it slowly reveals and closes the content: codepen.io/royketelaar/pen/avWxve
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$( ".product-description-full" ).hide();
$( document ).ready(function() {
$('.readmore').click(function (event) {
event.preventDefault();
var descriptionFull = document.querySelector('.product-description-full');
descriptionFull.style.display = 'block';
var descriptionShort = document.querySelector('.product-description-short');
descriptionShort.style.display = 'none';
});
$('.readless').click(function (event) {
event.preventDefault();
var descriptionFull = document.querySelector('.product-description-full');
descriptionFull.style.display = 'none';
var descriptionShort = document.querySelector('.product-description-short');
descriptionShort.style.display = 'block';
});
});
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<h2>This is a read more/less button demo</h2>
<p>This paragraph is above the read more/less button. </p>
<div class="product-description-short lessmore"><a href="#" class="readmore">Read More</a></div> <div class="product-description-full">
<h3>This header is below the read more button</h3>
<p>This paragraph is below the read more button. This is text to fill in space</p>
<div class="lessmore"><a href="#" class="readless">Read Less</a></div> </div>