jQuery to store initial value of textarea
<p>In the script below, I want to keep the initial value of htmlStrTOCpre static so that it does not change. However, once I edit the text area, the undo will no longer paste the original text back into the textarea. I believe its because the htmlStrTOCpre is based on the html() of textarea at the time the undoTOC function is called, and not the initial value on page load.</p>

<p>How can I store that initial value, so that I can always paste it back into the textarea (via the undoTOC function)?</p>

<pre><code>&lt;script&gt;
jQuery(document).ready(function()
    {
        var pageurl = jQuery("#sample-permalink").text();
        var htmlStrTOCpre = jQuery("#cb2_customTOC").html();
        var htmlStrTOC  = '&lt;h3&gt;Table of Contents&lt;/h3&gt;\n';
        htmlStrTOC += '&lt;ul&gt;\n';
        htmlStrTOC += '    &lt;li&gt;&lt;a href="'+pageurl+'"&gt;Introduction&amp;nbsp;&lt;/a&gt;&lt;/li&gt;\n';
        htmlStrTOC += '    &lt;li&gt;&lt;a href="'+pageurl+'2/"&gt;Introduction&amp;nbsp;&lt;/a&gt;&lt;/li&gt;\n';
        htmlStrTOC += '    &lt;li&gt;&lt;a href="'+pageurl+'3/"&gt;Conclusion&amp;nbsp;&lt;/a&gt;&lt;/li&gt;\n';
        htmlStrTOC += '&lt;/ul&gt;';

        var checkTOC = function()
        {
            jQuery("#cb2_customTOC").html(htmlStrTOC);
        }

        jQuery("#cb-toc-click").bind("click", checkTOC);

        var undoTOC = function()
        {
            jQuery("#cb2_customTOC").html(htmlStrTOCpre);
        }

        jQuery("#cb-toc-undo").bind("click", undoTOC);

&lt;/script&gt;

&lt;div id="post_TOC" class="postbox "&gt;
    &lt;h3 class="hndle"&gt;&lt;span&gt;Table of Contents&lt;/span&gt;&lt;/h3&gt;
    &lt;div class="inside"&gt;
        &lt;style&gt;
        .cb-toc{color:blue;text-decoration:underline;cursor:pointer;}
        &lt;/style&gt;
        &lt;div class="inside"&gt;
            &lt;textarea name="cb2_customTOC" id="cb2_customTOC"&gt;Some initial value&lt;/textarea&gt;
            &lt;span class="cb-toc" id="cb-toc-click"&gt;Paste TOC&lt;/span&gt; | &lt;span class="cb-toc" id="cb-toc-undo"&gt;Undo&lt;/span&gt;&lt;/p&gt;
        &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;

&lt;span id="sample-permalink"&gt;http://localhost:8888/test/&lt;/span&gt;
</code></pre>
