jQuery </div> tag causes NS_ERROR_XPC_BAD_CONVERT_JS
<p>I've got a form that allows visitors to add new form fields using an "add another" link.  It all works great but I'm trying to also get the form to include an "is this field required" checkbox and to do so I need to add some additional divs and that's where I'm running into a problem.  Here's my code:</p>

<pre><code>    if (requiredbox) {
        var openPrimary = '&lt;div class="form-item-primary"&gt;';
        var closePrimary = '&lt;/div&gt;';
        var openSecondary = '&lt;div class="form-item-secondary"&gt;\
            &lt;label class="box" for="' + fieldname + '_' + counter + '_required"&gt;' + fieldlabel + ' #' + counter + ' Required&lt;/label&gt;\
            &lt;input id="' + fieldname + '_' + counter + '_required" class="box" type="checkbox" value="yes" name="' + fieldname + '_' + counter + '_required"&gt;\
            &lt;span id="' + fieldname + '_' + counter + '_required" class="forminfo"&gt;&lt;/span&gt;\
            &lt;/div&gt;';
        var closeSecondary = '&lt;/div&gt;';
    }
    else {
        var openPrimary = '';
        var closePrimary = '';
        var openSecondary = '';
        var closeSecondary = '';
    }
    $('&lt;div class="form-item"&gt;\
    ' + openPrimary + '\
    &lt;label for="' + fieldname + '_' + counter + '"&gt;' + fieldlabel + ' #' + counter + '&amp;nbsp;&lt;a href="" class="remove rem_' + counter + '" id="rem' + fieldname + '"&gt;(Remove)&lt;/a&gt;&lt;/label&gt;\
    &lt;select id="' + fieldname + '_' + counter + '" name="' + fieldname + '_' + counter + '"' + addJS + '&gt;\
    &lt;option value=""&gt;Please Select&lt;/option&gt;\
    ' + optionlist + '\
    &lt;/select&gt;\
    ' + closePrimary + '\
    ' + openSecondary + '\
    ' + closeSecondary + '\
    &lt;/div&gt;').fadeIn("slow").appendTo('#' + fieldname + '_additions');       
    $('input#' + fieldname + '_count').val(counter);
    // Hide the "remove" link on the previous item (if applicable)
    if (counter &gt; mincounter) {
        $('.rem_' + (counter - 1)).hide();
    }
</code></pre>

<p>The error that I'm getting is Timestamp: 12/5/2012 10:47:10 AM
Error: NS_ERROR_XPC_BAD_CONVERT_JS: Could not convert JavaScript argument arg 0 [nsIDOMWindow.getComputedStyle]
Source File: <a href="http://mysite.com/scripts/jquery-1.8.2.js" rel="nofollow">http://mysite.com/scripts/jquery-1.8.2.js</a>
Line: 6812</p>

<p>Line 6812 is:
    computed = window.getComputedStyle( elem, null ),</p>

<p>I've narrowed down the problem to the line:</p>

<pre><code>var closePrimary = '&lt;/div&gt;';
</code></pre>

<p>If I change the closing div to ANYTHING else it works fine but I need that closing div tag for the layout, of course.  Does anyone know what I'm doing wrong here?</p>

<p>Thanks!</p>
