Why won't this text truncation javascript work?
<p>I found this snippet online which works to truncate text:</p>

<p><a href="http://www.barelyfitz.com/projects/truncate/" rel="nofollow">http://www.barelyfitz.com/projects/truncate/</a> </p>

<p>The problem is, the script puts the href inside the container where the text to be truncated lies and when clicked the rest of the test expands but the show more link (the dot dot dots) is gone. I need that link to always be present since I want the user to be able to toglle show more/less kind of like how they do in youtube.</p>

<p>How can he script be altered to work this way, or how will a new script for this look. This was my failed attempt to make the aforementioned script work the way I needed it to:</p>

<pre><code>&lt;script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"&gt;&lt;/script&gt;

&lt;p id="truncateMe" style="border: 1px solid red"&gt;Lorem ipsum dolor sit amet, consectetuer adipiscing
elit. Aenean consectetuer. Etiam venenatis. Sed ultricies, pede sit
amet aliquet lobortis, nisi ante sagittis sapien, in rhoncus lectus
mauris quis massa. Integer porttitor, mi sit amet viverra faucibus,
urna libero viverra nibh, sed dictum nisi mi et diam. Nulla nunc eros,
convallis sed, varius ac, commodo et, magna. Proin vel
risus. Vestibulum eu urna. Maecenas lobortis, pede ac dictum pulvinar,
nibh ante vestibulum tortor, eget fermentum urna ipsum ac neque. Nam
urna nulla, mollis blandit, pretium id, tristique vitae, neque. Etiam
id tellus. Sed pharetra enim non nisl.&lt;/p&gt;

&lt;div id="link"&gt;&lt;/div&gt;

&lt;script type="text/javascript"&gt;

var len = 100;
var p = document.getElementById('truncateMe');
if (p) {

  var trunc = p.innerHTML;
  if (trunc.length &gt; len) {

    /* Truncate the content of the P, then go back to the end of the
       previous word to ensure that we don't truncate in the middle of
       a word */
    trunc = trunc.substring(0, len);
    trunc = trunc.replace(/\w+$/, '');

    /* Add an ellipses to the end and make it a link that expands
       the paragraph back to its original size */
    trunc += '&lt;a href="#" ' +
      'onclick="this.parentNode.innerHTML=' +
      'unescape(\''+escape(p.innerHTML)+'\');return false;"&gt;' +
      '...&lt;\/a&gt;';
    p.innerHTML = trunc;


    trunc2 = '&lt;a href="#" ' +
      'onclick="$(\'truncateMe\').innerHTML=' +
      'unescape(\''+escape(p.innerHTML)+'\');return false;"&gt;' +
      'More&lt;\/a&gt;';


    $('#link').html(trunc2);

  }
}

&lt;/script&gt;
</code></pre>
