Removing Dynamic Elements and Reordering those Elements Values and ID's
<p>I have a function which creates a DOM element onClick. That Element contains inputs with <strong>array names</strong>.</p>

<p>At the start I <strong>already have one</strong> element (the same like those which I create onClick).</p>

<pre><code>&lt;tbody id="elementsBody"&gt;

&lt;tr id="element1"&gt; // 1 becomes 2 and so on when new element is added
  &lt;td&gt;
    &lt;input type="hidden" name="numbers[]" value="1" /&gt; // 1 becomes 2 and so on when new element is added
  &lt;/td&gt;
  &lt;td&gt;
    &lt;input type="text" name="titles[]" /&gt;
  &lt;/td&gt;
&lt;/tr&gt;

// Newly created Elements goes in here!!!

&lt;/tbody&gt;
</code></pre>

<p>This is my function which creates more elements like the one above.</p>

<p>And also <strong>creates a Delete Button DIV</strong> for this newly created element.</p>

<pre><code>function addElement() {
  var elementsBody = document.getElementById('elementsBody');

  var numbers = document.forms[1].elements['numbers[]'];
  var number = numbers.length+1;

  if (isNaN(number)) {
    var number = 2;
  }

  var numberInput = '&lt;td&gt;&lt;input type="hidden" name="numbers[]" value="'+ number + '" /&gt;&lt;/td&gt;';
  var titleTd = '&lt;td&gt;&lt;input type="text" name="titles[]" /&gt;&lt;/td&gt;';

  // This is the Delete Button DIV
  // I want to create a function (deleteElement) which Removes This Element
  var deleteButton = '&lt;td&gt;&lt;div onClick="deleteElement('+ number + ')"&gt;Delete Element&lt;/div&gt;&lt;/td&gt;';

  elementsBody.insertAdjacentHTML('beforeend', '&lt;tr id="element' + number + '"&gt;' + numberInput + titleTd + deleteButton + '&lt;/tr&gt;');
}
</code></pre>

<p><strong>I want to create a function (deleteElement) which Removes this Added Element</strong> onClick. </p>

<p>After Removing an Element, I want that function to <strong>reorder all the elements values and ID's</strong>. For example if I remove the Element number 2, the value and ID of the third Element must become 2.</p>

<p>Not JQuery.</p>

<p>Please Help me with that!</p>
