title: Add/remove multiple inputs jquery
body: <p>i have the code below</p>
  
  <pre><code>$(document).ready(function(){
  
      var input = '&lt;p&gt;&lt;input type="text" name="alternativas[]" /&gt; &lt;a href="#" class="remove"&gt;&lt;img src="images/ico_excluir.gif" /&gt;&lt;/a&gt;&lt;/p&gt;';
  
      $("input[name='add']").click(function( e ){
          $('#inputs').append( input );
      });
  
      $('#inputs').delegate('a','click',function(){
          $( this ).parent('p').remove();
      });
  
  });
  </code></pre>
  
  <p>and i have a lot of forms in the same page</p>
  
  <pre><code>    &lt;table width="100%" border="0" cellspacing="10" cellpadding="0" div="alter"&gt;
  &lt;form action="/teste/fono2014/admin/pesquisa_editar.php" method="get" enctype="multipart/form-data"&gt;
        &lt;tr&gt;
      &lt;td colspan="2" align="center"&gt;&lt;h3&gt;QUESTION 1&lt;/h3&gt;&lt;/td&gt;
      &lt;/tr&gt;  
    &lt;tr&gt;
      &lt;td width="30%" align="right"&gt;Question:&lt;/td&gt;
      &lt;td&gt;&lt;input type="text" value="Where are you from?" /&gt;&lt;/td&gt;
      &lt;/tr&gt;
  
      &lt;tr&gt;
      &lt;td align="right"&gt;Sequence:&lt;/td&gt;
      &lt;td&gt;&lt;input name="ordem_pergunta" type="text" value="1" onkeypress='return SomenteNumero(event)' /&gt;&lt;/td&gt;
      &lt;/tr&gt;
          &lt;tr&gt;
      &lt;td align="right"&gt;Alternatives:&lt;/td&gt;
      &lt;td&gt;&lt;input type="button" name="add" value="Add" /&gt;
      &lt;div id="inputs"&gt;
              &lt;p&gt;&lt;input type="text" name="alternativas[]" value="Brazil" /&gt; &lt;a href="#" class="remove"&gt;Remove&lt;/a&gt;&lt;/p&gt;
              &lt;p&gt;&lt;input type="text" name="alternativas[]" value="EUA" /&gt; &lt;a href="#" class="remove"&gt;Remove&lt;/a&gt;&lt;/p&gt;
              &lt;p&gt;&lt;input type="text" name="alternativas[]" value="Mexico" /&gt; &lt;a href="#" class="remove"&gt;Remove&lt;/a&gt;&lt;/p&gt;
    &lt;/div&gt;
  &lt;/td&gt;
      &lt;/tr&gt;
          &lt;tr&gt;
      &lt;td align="right"&gt;More than one?&lt;/td&gt;
      &lt;td&gt;&lt;input name="inserir_varios" type="radio" value="S" checked&gt;
        Yes &lt;input name="inserir_varios" type="radio" value="N" &gt;
        No&lt;/td&gt;
      &lt;/tr&gt;
      &lt;/form&gt;
      &lt;form action="/teste/fono2014/admin/pesquisa_editar.php" method="get" enctype="multipart/form-data"&gt;
        &lt;tr&gt;
      &lt;td colspan="2" align="center"&gt;&lt;h3&gt;QUESTION 2&lt;/h3&gt;&lt;/td&gt;
      &lt;/tr&gt;  
    &lt;tr&gt;
      &lt;td align="right"&gt;Question:&lt;/td&gt;
      &lt;td&gt;&lt;input name="pergunta" type="text" value="How old are you?" /&gt;&lt;/td&gt;
      &lt;/tr&gt;
  
      &lt;tr&gt;
      &lt;td align="right"&gt;Sequence:&lt;/td&gt;
      &lt;td&gt;&lt;input name="ordem_pergunta" type="text" value="2" onkeypress='return SomenteNumero(event)' /&gt;&lt;/td&gt;
      &lt;/tr&gt;
          &lt;tr&gt;
      &lt;td align="right"&gt;Alternatives:&lt;/td&gt;
      &lt;td&gt;&lt;input type="button" name="add" value="Add" /&gt;
      &lt;div id="inputs"&gt;
              &lt;p&gt;&lt;input type="text" name="alternativas[]" value="&amp;lt; 18" /&gt; &lt;a href="#" class="remove"&gt;Remove&lt;/a&gt;&lt;/p&gt;
              &lt;p&gt;&lt;input type="text" name="alternativas[]" value="&amp;gt; 18" /&gt; &lt;a href="#" class="remove"&gt;Remove&lt;/a&gt;&lt;/p&gt;
    &lt;/div&gt;
  &lt;/td&gt;
      &lt;/tr&gt;
          &lt;tr&gt;
      &lt;td align="right"&gt;More than one?&lt;/td&gt;
      &lt;td&gt;&lt;input name="inserir_varios" type="radio" value="S" checked&gt;
        Yes &lt;input name="inserir_varios" type="radio" value="N" &gt;
        No&lt;/td&gt;
      &lt;/tr&gt;
  
      &lt;/form&gt;
      &lt;form action="/teste/fono2014/admin/pesquisa_editar.php" method="get" enctype="multipart/form-data"&gt;
        &lt;tr&gt;
      &lt;td colspan="2" align="center"&gt;&lt;h3&gt;QUESTION 3&lt;/h3&gt;&lt;/td&gt;
      &lt;/tr&gt;  
    &lt;tr&gt;
      &lt;td align="right"&gt;Question:&lt;/td&gt;
      &lt;td&gt;&lt;input name="pergunta" type="text" value="Where do you live?" /&gt;&lt;/td&gt;
      &lt;/tr&gt;
  
      &lt;tr&gt;
      &lt;td align="right"&gt;Sequence:&lt;/td&gt;
      &lt;td&gt;&lt;input name="ordem_pergunta" type="text" value="3" onkeypress='return SomenteNumero(event)' /&gt;&lt;/td&gt;
      &lt;/tr&gt;
          &lt;tr&gt;
      &lt;td align="right"&gt;Alternatives:&lt;/td&gt;
      &lt;td&gt;&lt;input type="button" name="add" value="Add" /&gt;
      &lt;div id="inputs"&gt;
              &lt;p&gt;&lt;input type="text" name="alternativas[]" value="New York" /&gt; &lt;a href="#" class="remove"&gt;Remove&lt;/a&gt;&lt;/p&gt;
              &lt;p&gt;&lt;input type="text" name="alternativas[]" value="San Diego" /&gt; &lt;a href="#" class="remove"&gt;Remove&lt;/a&gt;&lt;/p&gt;
    &lt;/div&gt;
  &lt;/td&gt;
      &lt;/tr&gt;
          &lt;tr&gt;
      &lt;td align="right"&gt;More than one?&lt;/td&gt;
      &lt;td&gt;&lt;input name="inserir_varios" type="radio" value="S" &gt;
        Yes &lt;input name="inserir_varios" type="radio" value="N" checked&gt;
        No&lt;/td&gt;
      &lt;/tr&gt;
      &lt;/form&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>When i click add the code just add the new input on the first div. 
  What can i do ?</p>
  
  <p>i have no ideia what i can do, i don't know jquery very well. i thought to put a random variable on id to each form and the button "Add" get this id, but i dont know how to do it.</p>