Skip to content
Advertisement

how to clone the main document dom in javascript?

I try to clone my document node but it’s not working.

I try this code

const dom = document.clone(true);

I have this error

TypeError: document.clone is not a function

I thinkg it’s very simple but i don’t find yet.

Thanks for help

Advertisement

Answer

Don’t you mean cloneNode

const dom = document.cloneNode(true);

console.log(dom);
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement