Create form and input field through javascript
<p>I am doing my javascript assignment in which I have a form and there are multiple buttons in it. I want that javascript should render like</p>

<pre><code>&lt;form&gt;
&lt;input /&gt;
&lt;button /&gt;
&lt;/form&gt;
</code></pre>

<p>but it is rendering like this</p>

<pre><code> &lt;form&gt; &lt;/form&gt;
    &lt;input /&gt;
    &lt;button /&gt;
</code></pre>

<p>sample code</p>

<pre><code>var formTag = document.createElement('form');
document.body.appendChild(formTag);
var txtInput = document.createElement("input");
var txtNode = document.createTextNode("0");
txtInput.setAttribute("id", "txtInput");
txtInput.appendChild(txtNode);
document.form.appendChild(txtInput);
</code></pre>
