vikrantnegi
1/13/2017 - 9:06 AM

Readmore for multi-paragraph

Readmore for multi-paragraph

var readMore = $('<div id="read-more" class="read-more">Read more +</div>');
var readLess = $('<div id="read-less" class="read-less">Read Less -</div>');

var firstPara = $('.product-single__description.rte p:first');

var lastPara = $('.product-single__description.rte p:last');

var notFirstPara = $('.product-single__description.rte p:not(:first)');

notFirstPara.hide();

firstPara.append(readMore);
  
$('#read-more').on('click', function(){
  notFirstPara.show();
  readMore.hide();
  lastPara.append(readLess);
  
  $('#read-less').on('click', function(){
    notFirstPara.hide();
    readMore.show();
  });
});