How to set attributes on dynamically created elements in JavaScript
<p>I'm trying to understand HTML elements that are dynamically created with JavaScript.  Specifically can someone explain why if I create a button in HTML with no value attribute it will appear with no text.  I can then add a value to it and the text will appear in the button, and I can also alert the value like so:</p>

<pre><code>var Button1 = document.getElementById("Button1");
Button1.value = "test";
alert(Button1.value);
</code></pre>

<p>BUT, if I generate the button dynamically and then add the value it does NOT appear on the button, although I can still alert it.</p>

<pre><code>var Button1 = document.createElement("button");
var Div1 = document.getElementById("Div1");
Button1.value = "test";
Div1.appendChild(Button1);
alert(Button1.value);
</code></pre>

<p>In the second example, the text of the button doens't change, but the value still alerts.  I KNOW that I can use createTextNode and append it to the button, but I'm trying to understand the difference between controls generated dynamically through JavaScript and those that are created in HTML.</p>

<p>Thank you for reading my question.</p>
