jquery .before() no unclosed tags allowed
<p>have a function in jquery to automatically create the tab elements for a product in ecommerce system.</p>

<pre><code>function structureTabs()
{
    $('#tabs').prepend('&lt;ul id="tabbtns"&gt;&lt;/ul&gt;');

    $('#tabs h2').each(function(index){

        if(index &gt; 0)
        {
            $(this).before('&lt;/div&gt;&lt;div id="tabs-'+(index+1)+'"&gt;');
        }
        else
        {
            $(this).before('&lt;div id="tabs-'+(index+1)+'" class="jackie"&gt;');
        }

        var title = $(this).text();

        $('#tabbtns').append('&lt;li&gt;&lt;a href="#tabs-' + (index+1) + '"&gt;' + title + '&lt;/a&gt;&lt;/li&gt;');

    });

    $('#tabs').append('&lt;/div&gt;');
}
</code></pre>

<p>You cannot put unclosed tabs into .before()??</p>

<p>Basically the content this is trying to wrap around is:</p>

<pre><code>&lt;div id="tabs"&gt;
&lt;h2&gt;Details&lt;/h2&gt;
details text...
&lt;h2&gt;tech specs&lt;/h2&gt;
tech spec text...
&lt;h2&gt;Video Sample&lt;/h2&gt;
video embed url
&lt;/div&gt;
</code></pre>

<p>The client of the eccomerce store can't edit html, so need to build the tabs automatically in .js....</p>
