Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
89
rated 0 times [  96] [ 7]  / answers: 1 / hits: 70804  / 12 Years ago, thu, august 16, 2012, 12:00:00

How can I using javascript make clone of some <div> and set his id different from original. Jquery also will be nice.


More From » jquery

 Answers
7
var div = document.getElementById('div_id'),
clone = div.cloneNode(true); // true means clone all childNodes and all event handlers
clone.id = some_id;
document.body.appendChild(clone);

[#83605] Tuesday, August 14, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kelsy

Total Points: 486
Total Questions: 86
Total Answers: 76

Location: El Salvador
Member since Sun, Sep 12, 2021
3 Years ago
kelsy questions
Tue, Oct 19, 21, 00:00, 3 Years ago
Tue, Aug 4, 20, 00:00, 4 Years ago
Wed, Jun 17, 20, 00:00, 4 Years ago
Fri, Jan 10, 20, 00:00, 4 Years ago
;