title: script successfully adding textfield but below the previous instead of above
body: <p>I'm using this script for adding a textfield after adding the data to previous one , but the next textfield gets incremented at the bottom of previous. I want the blank textfield above the previous one. Please help on this. </p>
  
  <pre><code>var next1 = 1;
                  $(".add-more1").click(function(e){
                      e.preventDefault();
                      var addto1 = "#fld" + next1;
                      var addRemove1 = "#fld" + (next1);
                      next1 = next1 + 1;
                      var newIn1 = '&lt;input list="type" id="type' + next1 +'" name="type' + next1 + '"   placeholder="Select type"&gt; ';
                      var newIn2 = '&lt;input class="input"  list="name" id="fld' + next1 + '" name="fld' + next1 + '" placeholder="Add member"/&gt;';
                      var newInput1 = $(newIn1);
                      var newInput2 = $(newIn2);
                      var removeBtn1 = '&lt;button id="remove' + (next1 - 1) + '" class="btn btn-danger remove-me" &gt;-&lt;/button&gt;&lt;/div&gt;&lt;div id="fld"&gt;';
                      var removeBtn1 = '&lt;button id="remove' + (next1 - 1) + '" class="btn btn-danger remove-me" &gt;-&lt;/button&gt;&lt;/div&gt;&lt;div id="type"&gt;';
                      var removeButton1 = $(removeBtn1);
  
  
                      $(addto1).after(newInput2);
                      $(addto1).after(newInput1);
                      $(addRemove1).after(removeButton1);
                      $("#type" + next1).attr('data-source',$(addto1).attr('data-source'));
                      $("#fld" + next1).attr('data-source',$(addto1).attr('data-source'));
                     // $("#count").val(next1);  
  
                          $('.remove-me').click(function(e){
                              e.preventDefault();
                              var fieldNum1 = this.id.charAt(this.id.length-1);
                              var fieldID1 = "#fld" + fieldNum1;
                              $(this).remove();
                              $(fieldID1).remove();
                              var fieldNum2 = this.id.charAt(this.id.length-1);
                              var fieldID2 = "#type" + fieldNum2;
                              $(this).remove();
                              $(fieldID2).remove();
                          });
                  });
  </code></pre>