+ 5
How to clone a tag and modify the clone tag without changing the original one?
I can clone a tag of HTML. Here is the code: https://code.sololearn.com/WA19a23a7A9a Now I need to modify only the cloned tag. How can I do that? Thanks in advance.
6 Respuestas
+ 4
What do you mean by changing the cloned tag position?
+ 2
If you want to change the position where the cloned tag is inserted, you can use other methods like prepend (), insertAdjacentElement (), etc.
+ 1
Avinesh , I mean using top,left,bottom ,right to position the element .
+ 1
Try this 😜
var myDiv = document.getElementById("test").cloneNode(true);
myDiv.append(" cloned")
document.body.prepend(myDiv);
+ 1
Change the id of clone
0
@Eze sorry for asking but can you please give an example as I don't know the use of those tags?