title: Trim text using Jquery with clickable "More" but keep text format
body: <p>I want t use the below Jquery to truncate the text in the div ID="content" below, but I want to keep the text format too, as when I use the jquery I lose<code>&lt;br&gt;</code> im the text which works as paragraph separator.</p>
  
  <p>How can I fix that?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var minimized_elements = $('#content'); 
  
  minimized_elements.each(function() {
    var t = $(this).text();
    if (t.length &lt; 300) return;
  
    $(this).html(
      t.slice(0, 300) + '&lt;span&gt;... &lt;/span&gt;&lt;a href="#" class="more"&gt;More&lt;/a&gt;' +
      '&lt;span style="display:none;"&gt;' + t.slice(300, t.length) + ' &lt;a href="#" class="less"&gt;Less&lt;/a&gt;&lt;/span&gt;'
    );
  
  });
  
  $('a.more', minimized_elements).click(function(event) {
    event.preventDefault();
    $(this).hide().prev().hide();
    $(this).next().show();
  });
  
  $('a.less', minimized_elements).click(function(event) {
  event.preventDefault();
  $(this).parent().hide().prev().show().prev().show();
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;div id="content"&gt;
   It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content content
      here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text
    
    &lt;br&gt;
    &lt;br&gt;
   It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text
  
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>