selecting HTML from a document using Javascript
<p>I want to get a HTML selection out of the document.</p>

<p>Say, I have <code>&lt;u&gt;Hi &lt;i&gt;I am &lt;b&gt;TOM&lt;/b&gt;&lt;/i&gt;&lt;/u&gt;</code> displayed.</p>

<p>I want to select <code>am TO</code>.</p>

<p>The following JS</p>

<pre><code>var span = document.createElement( 'SPAN' );
span.appendChild( window.getSelection().getRangeAt(0).cloneContents() );
span.innerHTML;
</code></pre>

<p>only displays <code>am &lt;b&gt;TO&lt;/b&gt;</code>. Rest of the tags which have influence on the selection are lost.</p>

<p>Is there any way to get these lost tags under selection too?</p>

<p>Thanks :)</p>
