How to get form html() via jQuery including <form></form> tag?
<p>I want to display my <strong>form</strong> html content into a textarea which allows the user to edit form elements via user interface. Here is my form,</p>

<pre><code>&lt;form name="myform" action="abc.php"&gt;
    &lt;input type="radio" name="radio1" value="1" checked&gt;
    &lt;input type="radio" name="radio2" value="2"&gt;&lt;br&gt;&lt;br&gt;
    &lt;input type="text" name="input" value="My Name" /&gt;
&lt;/form&gt;
</code></pre>

<p>I tried below code, but it display's the form elements only (not includes the form tag).</p>

<pre><code>&lt;script&gt;
$(document).ready(function() 
{
    $('a').on('click', function() { 
        $("input,select,textarea").each(function() {
           if($(this).is("[type='checkbox']") || $(this).is("[type='checkbox']")) {
             $(this).attr("checked", $(this).attr("checked"));
           }
           else {
              $(this).attr("value", $(this).val()); 
           }
        });
        alert($('form').html());
    });
});
&lt;/script&gt;
</code></pre>

<p>Above code alerts an output like below,</p>

<pre><code>&lt;input type="radio" name="radio1" value="1" checked&gt;
&lt;input type="radio" name="radio2" value="2"&gt;&lt;br&gt;&lt;br&gt;
&lt;input type="text" name="input" value="My Name" /&gt;
</code></pre>

<p>But I need an output like below,</p>

<pre><code>&lt;form name="myform" action="abc.php"&gt;
    &lt;input type="radio" name="radio1" value="1" checked&gt;
    &lt;input type="radio" name="radio2" value="2"&gt;&lt;br&gt;&lt;br&gt;
    &lt;input type="text" name="input" value="My Name" /&gt;
&lt;/form&gt;
</code></pre>