Setting the value of a dynamically created text box with jQuery
<p>Using the following code</p>

<pre><code>var newDiv = $(document.createElement("div"));
var newTextBox;

newTextBox = $(document.createElement("input"))
    .attr("type", "text")
    .attr("id", "textbox")
    .attr("name", "textbox");

newTextBox.val("text");
newDiv.append(newTextBox);
alert(newDiv.html());
</code></pre>

<p>I get the following</p>

<pre><code>&lt;input name="textbox" id="textbox" type="text"&gt;
</code></pre>

<p>I get the same thing with </p>

<pre><code>$("#textbox").val("test");
</code></pre>

<p>Using</p>

<pre><code>newTextBox = $("&lt;input/&gt;");
</code></pre>

<p>Doesn't help either</p>

<p>Where is my value?</p>

<p><strong>EDIT: SOLTUION</strong></p>

<p>So, further up in the stack I was converting the DOM I built to a string and since - like munch mentioned - the dynamic value doesn't get added to the tag, it wasn't showing up.  </p>

<p>Thanks for the help</p>
