KAMRUL HASAN
KAMRUL HASAN

Reputation: 55

How to duplicate form div elements?

This code is not working when I am trying to duplicate form elements or DIV.But the code is working when removing form tag.I want to be able to duplicate Div under form Tag using plain javascript.

function display(){
    var a = document.getElementsById('clone');
    var b = document.getElementsByID('group');
    var c = b.cloneNode(true);
    a.appendChild(c);
}

Upvotes: 0

Views: 59

Answers (1)

Brada
Brada

Reputation: 46

I see that you have mistyped document.getElementsByID('group'). The function name should be getElementById.

Also for future, you can use the developer console console to see if there is something wrong.

Upvotes: 3

Related Questions