Convert DOM elements to HTML Code and display in an on-page textarea?
<p>I have the need to grab a few DOM Elements from an HTML page and emit their HTML (code) into a textarea on the same page.  The purpose is to allow the viewer to copy and paste the code into their own pages.</p>

<p>Is this even possible?</p>

<p>I've tried something like (in jQuery):</p>

<pre><code>$('textarea').val( $('.container').html() );
</code></pre>

<p>Where I've first cloned the elements I require into a <code>div.container</code>, but that just gives me something like <code>object #&lt;HTMLImageElement&gt;</code> in my textarea.  What I was hoping to get was something like <code>&lt;img src="http://www.domain.com/images/file.png" alt="My Image"&gt;</code> according to the structure of the elements I cloned.</p>

<p>Any pointers appreciated! Thanks!</p>
