title: add input field with number increase & back to 2 after remove field
body: <p>Here is the code to add an input field <code>if button</code> named "add" and when clicked the value number will increase (EX: number 1, number 2 &amp; etc)</p>
  
  <p>When I remove input field which is added, the number will continue to number 4, 5. if I click button "add" again, it should back to 1, 2, 3 ...</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$(function() {
    var ijk = 2;
    $("#btnAdd").bind("click", function() {
      var add = '&lt;div class="row"&gt;&lt;div class="col-sm-1"&gt;&lt;strong&gt;Domain ' + ijk + ' &lt;/strong&gt;&lt;/div&gt;' + '&lt;div class="col-sm-4"&gt;&lt;input name = "DynamicTextBox"  class="form-control" type="text" value = "" /&gt;&lt;/div&gt;' + '&lt;div class="col-sm-1"&gt;&lt;button class="remove btn btn-danger"&gt;cancel&lt;/button&gt;&lt;/div&gt;&lt;/div&gt; &lt;br /&gt;';
      $("#TextBoxContainer").append(add);
      ijk++;
    });
  
    $("body").on("click", ".remove", function() {
      $(this).closest(".row").remove();
    });
  
  });</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.col-sm-1 {
    float: left;
    width: 100px
  }
  
  .col-sm-4 {
    float: left;
    width: 170px
  }
  
  .row {
    clear: both
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"&gt;&lt;/script&gt;
  &lt;div class="row"&gt;
    &lt;div class="col-sm-1"&gt;&lt;strong&gt;Domain 1&lt;/strong&gt;&lt;/div&gt;
    &lt;div class="col-sm-4"&gt;&lt;input type="text" 2 id=""&gt;
    &lt;/div&gt;
    &lt;div class="col-sm-1"&gt;
      &lt;button id="btnAdd" type="button" class="btn btn-secondary"&gt;Add&lt;/button&gt;
    &lt;/div&gt;
  
  &lt;/div&gt;
  &lt;br&gt;
  
  &lt;div id="TextBoxContainer"&gt;
    &lt;!--Textboxes will be added here --&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>