I have made elements using this function:
    var counterUpload = 1;
     var limit = 20;
     function addUpload(divName){
     if (counterUpload == limit)  {
          alert("You have reached the limit of adding " + counterUpload + " inputs");
     }
     else {
      var newdiv = document.createElement('p');
          newdiv.innerHTML = " <label>Offences: * </label><input required=\"required 
                              \"style=   \"width:670px;\"type=\"text\"
                               name=\"offences["+counterUpload+"]\" 
                               id=\"offences["+counterUpload+"]\"> "
      document.getElementById(divName).appendChild(newdiv);
      counterUpload++;
     }
}
here is my html
<fieldset class="ro5" id="ro5"> <legend>Add New:</legend> <p> <label>Offences: *  </label> <input name="offences" style="width:670px;" type="text" required="required"/>  </p>
divName takes ro5 as argument
this is what i have tried so far:
function removeUpload(divName){
if (limit==counterUpload)  {
  alert("You have reached the limit of removing " + counterUpload + " inputs");
}
else {
  var newdiv = document.removeElement('p');
  if(
  newdiv.innerHTML = " <label>Offences: * </label><input required=\"required\" style=\"width:670px;\"type=\"text\" name=\"offences["+counterUpload+"]\" id=\"offences["+counterUpload+"]\"> "){
  document.getElementById(divName).removeChild(newdiv);}
  counterUpload--;
}
}
from the two answers so far, i have managed to come up with this but still it doesnot get the job done,i feel very close yet far:
function removeUpload(divName) {
// Find the parent element
var parent = document.getElementById(divName);
if (parent) {
    // Find all the child nodes in parent element
    var children = parent.getElementsByTagName("P");
var num=count(children);
for(i = num; i >2 ; i--){
//i gave the P elements to remove an id="paraE" so that i do not remove other P elements //with out this id
    if( children[i].getAttribute('id') == 'paraE'){ 
        parent.removeChild(children[i]);
    } 
    }
}
how can I delete the elements?how can I reverse this function to do the opposite work???
 
     
     
    
` children before your function starts?
– PM 77-1 Jul 07 '14 at 20:20