title: How to add input fields on button click
body: <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 add() {
    var new_chq_no = parseInt($('#total_chq').val()) + 1;
    var new_input = "&lt;input type='text' id='new_" + new_chq_no + "'&gt;";
    $('#new_chq').html(new_input);
  }
  
  function remove() {
    var last_chq_no = $('#total_chq').val();
    if (last_chq_no &gt; 1) {
      $('#new_' + last_chq_no).append('');
      $('#total_chq').val(last_chq_no - 1);
    }
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;input type="text"&gt;
  &lt;button onclick="add()"&gt;Add&lt;/button&gt;
  &lt;button onclick="remove()"&gt;remove&lt;/button&gt;
  &lt;div id="new_chq"&gt;&lt;/div&gt;
  &lt;input type="hidden" value="1" id="total_chq"&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>its adding input fields one time and on second click its not adding anything and remove button is not working</p>