How can I modify the returned value of jQuery's html() method?
<p>I have a div that I want to write to a popup window (for printing).</p>

<p>I'm grabbing the contents of the div's I want on the page using jQuery's html() function like so:</p>

<pre><code>function printOptions() {
        var printwindow = window.open('', 'Report', 'height=600,width=600');
        printwindow.document.write('&lt;html&gt;&lt;head&gt;&lt;title&gt;Report&lt;/title&gt;');
        printwindow.document.write('&lt;/head&gt;&lt;body&gt;');
        printwindow.document.write($('#ReportHeader').html());
        printwindow.document.write($('#ReportData').html());
        printwindow.document.write('&lt;/body&gt;&lt;/html&gt;');
        printwindow.document.close();
        printwindow.print();
        return true;
    }
</code></pre>

<p>However, before I document.write() the contents of the #ReportHeader and #ReportData div's, I would like to alter them a little.</p>

<p>Specifically, I would like to replace all textboxes with a simple span containing that textboxes value.</p>

<p>Something like:</p>

<pre><code>$("input[type=text]").each(function() {
    $(this).replaceWith("&lt;span&gt;" + $(this).val() + "&lt;/span&gt;"); 
});
</code></pre>

<p>How can I do that to just the contents of those divs without altering my existing page?  I just want to modify what I'm going to be writing out to the print window.  I don't think I can select on what the html() returns though, because it is just returning a string.  </p>

<p>I do ~not~ want to modify the original page that is launching the popup.  Just the contents of what I'm going to be writing to the popup.</p>

<p>Any ideas on how I could do this?</p>
