Use jQuery to insert a script which includes a function?
<p>I am trying to append a line of JavaScript to a div dynamically, but it seems that when I run the .append() call, the browser sees a function() call within that line as an actual function instead of an actual string:</p>

<pre><code>var startDate = 0
...
function insertCalendar(){
    var divName = "div[name=StartDate" + startDateNum + "]";
    $(divName).append("&lt;script&gt;Calendar.setup({ trigger : 'StartDate" + startDateNum + "', inputField : 'StartDate" + startDateNum + "', onSelect : function() { this.hide() } });&lt;/script&gt;");
    startDateNum++;
}
</code></pre>

<p>At the call to .append() the JavaScript console returns "Uncaught SyntaxError: Unexpected end of input," and it seems to mess with the function insertCalendar. I'm fairly certain I'm not missing a quote...</p>

<p>Let me know if this is too vague as this is my first question here. Thanks!</p>
