Javascript DOM tree duplicate for manipulation

后端 未结 3 656
旧时难觅i
旧时难觅i 2021-01-05 23:42

Since the DOM tree of a page is active and always reflected in the browser, what is the best way to modify this DOM tree for some purpose without affecting the actual render

3条回答
  •  孤城傲影
    2021-01-06 00:00

    You can use document.cloneNode(true), or the same method on another node. cloneNode clones any node, and the true means it should be recursive (deep). Obviously, this could have a significant performance cost on a large page.

提交回复
热议问题