Remove cloned DIV by clicking button

1

At some point I asked a question about how to clone a DIV of a form by clicking a button (+) ...

I got the following answer that helped me back then.

  

ANSWER

Now, I need to add a new button (-) so that when the user clicks, the cloned div is removed.

Current JS code:

  

Prepared by: Sergio

function mais() {
    var destino = document.getElementById("aqui");
    var novadiv = document.createElement("div");
    var conteudo = document.getElementById("servico");
    novadiv.innerHTML = conteudo.innerHTML;
    destino.appendChild(novadiv);
}

I need help implementing a function that does the following:

function menos(){
    //remove ultima div clonada...
}

jsFiddle: jsfiddle.net/qf2Lf914/

    
asked by anonymous 11.11.2015 / 07:00

1 answer

2

So?

function menos()
{
    var destino = document.getElementById("aqui");
    if (destino.lastChild)
    {
        destino.removeChild(destino.lastChild);
    }
}

link

    
11.11.2015 / 07:35