(See more) in long product descriptions

(See more) in long product descriptions

Mohamed-28
Excursionist
31 1 3

Hello guys , 

please i need help to put (see more) button in product description .

i want to put it after maybe 3 line see more and see less .

thanks alot 

Replies 3 (3)

Perennial
Shopify Partner
1474 115 234
Hi,
Hope you doing well
Follow these 2 steps and code in theme.liquid file and product.liquid file.
 
<!-- theme.liquid code -->
 
{% if template == "product" %} 
<script type="text/javascript">
jQuery(document).ready(function($)
                             {
        //   $('.fulltext').hide();
 
        $('.readmore').insertAfter( '.product-description' );
 
        $('.readmore').click(function (event) {
          event.preventDefault();
          var description = document.querySelector('.product-description');
          console.log(description.style.height)
          if (description.style.height === ''){
            description.style.height = 'auto';
          } else if (description.style.height === 'auto'){
            description.style.height = '';
          }
          else{
            description.style.height = '92px';
          }
 
          $(this).text($(this).text() == 'Read less...' ? 'Read more...' : 'Read less...');
        });
      });
</script>
{% endif %} 
<style>
.product-description {
  height:200px;
  overflow: hidden;
 }
</style>
 
 
 
<!-- product.liquid code -->
<div class="product-collapes">
            <div class="product-description rte" itemprop="description">
              {{ product.description }}
            </div>
            <a class="readmore" href="#">Read more...</a>
          </div>

 

if you face any issue let me know

 
 
Mohamed-28
Excursionist
31 1 3

thanks alot dear , just want to know where exactly should i paste the ? after which part ?
thanks alot 

Mohamed-28
Excursionist
31 1 3

hello friend , 

i tried to paste it , and honstly it worked and shown in the description after few lines .

 

BUT 

when i click on it nothing happen and it doesn't show the rest of the description . 

waiting for you help 
Thanks