filmov
tv
JavaScript How to copy an existing element of the site?

Показать описание
There is some site.
There is a header on that site.
Let’s identify that element as header.
To clone the header we need to get this element first.
Then we need the cloneNode method to make a copy.
The cloneNode method has one parameter, DeepCopy.
The DeepCopy parameter should be true to copy the header with text.
Let’s change the identifier of the clone.
And then let’s append the clone to the body of the document.
That’s all.
Let’s do it by a click on the document.
Clone.
Clone.
Clone.
There is a header on that site.
Let’s identify that element as header.
To clone the header we need to get this element first.
Then we need the cloneNode method to make a copy.
The cloneNode method has one parameter, DeepCopy.
The DeepCopy parameter should be true to copy the header with text.
Let’s change the identifier of the clone.
And then let’s append the clone to the body of the document.
That’s all.
Let’s do it by a click on the document.
Clone.
Clone.
Clone.