title: jQuery how to auto adjust the number list when 1 of the list is removed?
body: <p>I want to automatically adjust the number list that was created using <code>.append()</code>. Example, if there are 4 items added on the list which will numbered from 2-4 respectively and if I removed item number 3, the item number 4 will automatically be number 3 and if I add a new item, it will be the last on the list. Here's my code below.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$('#display').click(function() {
    $('#show').show();
  });
  var c = 1;
  $('#append').click(function() {
    var cnt = $('.cnt').val();
    for (var i = 0; i &lt; cnt; i++) {
      c++;
      $('#inputs').append("&lt;div id='inputs' name='" + c + "'&gt;" + c + ".)&lt;button id='remove' name='" + c + "'&gt;X&lt;/button&gt;&lt;/div&gt;");
    }
  });
  $(document).on('click', '#inputs #remove', function() {
    var nm = $(this).attr('name');
    $('div[name="' + nm + '"]').remove();
    c--;
  });</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>#show {
    display: none;
  }</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;script src="https://raw.githubusercontent.com/igorescobar/jQuery-Mask-Plugin/master/src/jquery.mask.js"&gt;&lt;/script&gt;
  &lt;button id='display'&gt;Display&lt;/button&gt;
  &lt;div id='show'&gt;
    &lt;br&gt;
    &lt;input type='text' class='cnt' value='1' placeholder="num of append" /&gt;
    &lt;button id='append'&gt;+&lt;/button&gt;
    &lt;br&gt;
    &lt;div id='inputs'&gt;
      1.)
    &lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Here is the <a href="http://jsfiddle.net/2e0qyrq3/5/" rel="nofollow noreferrer">jsfiddle</a> of the code.</p>