Jquery: dynamic form
<p>I'm in need of a dynamic form that will be built from a list of inputs (hidden by default) depending on select input value.</p>

<p>The only problem I face is to show/hide form elements. I have following code:</p>

<pre><code>            var form = $("#form");
            var type = $("select[name=type]").val();

            switch(type){
                case 'image':
                    form.html($("#title, #src"));
                    break;
                case 'video':
                    form.html($("#title, #url"));
                    break;
                case 'text':
                    form.html($("#title, #body"));
                    break;
                case 'generate':
                    form.html($("#title, #src));
                    break;
            }
</code></pre>

<p>My question is: how to add/remove object child elements dynamically? Inputs are stored in separate <code>&lt;div&gt;</code> element - I need to add or remove them as child element of <code>#form</code> div.</p>
