Delete a selected form element
<p>I have a form element that needs to be deleted when a button next to the element is clicked.</p>

<pre><code>   $('#btnDel').click(function() {

        var num = $('#input').prevAll().size();
        $('#form div:nth-child('+ num +')').remove();

      }
</code></pre>

<p>Can't seem to get that working! Any help very much appreciated. I think I'm just confused with selecting the right element...</p>

<p>EDIT: with markup as requested:</p>

<pre><code>    &lt;div id="form"&gt;
&lt;form name="create" method="post" action="create.php"&gt;

 &lt;input type="hidden" id="id" value="1"&gt;

    &lt;label for="title"&gt;Title&lt;/label&gt;
    &lt;input name="myusername" type="text" id="myusername"&gt;&lt;br /&gt;&lt;br /&gt;
    &lt;div id="input" class="clonedInput"&gt;
        Question: &lt;input type="text" name="question" id="question" /&gt;
        &lt;input type="button" id="btnDel" value="Remove question" /&gt;
    &lt;/div&gt;
    &lt;div&gt;
        &lt;input type="button" id="btnAdd" value="Add another question" /&gt;
    &lt;/div&gt;
    &lt;input type="submit" name="submit" value="Create survey"&gt;

&lt;/form&gt;

&lt;/div&gt;
</code></pre>
