← Back to DOM domain

DOM.copyTo

Creates a deep copy of the specified node and places it into the target container before the given anchor.

Domain: DOM experimental

Parameters

NameTypeDescription
nodeIdNodeIdId of the node to copy.
targetNodeIdNodeIdId of the element to drop the copy into.
insertBeforeNodeId (optional)NodeIdDrop the copy before this node (if absent, the copy becomes the last child of `targetNodeId`).

Returns

NameTypeDescription
nodeIdNodeIdId of the node clone.

Example Request

{
  "id": 1,
  "method": "DOM.copyTo",
  "params": {
    "nodeId": 1,
    "targetNodeId": "targetNodeId-value"
  }
}

Example Response

{
  "id": 1,
  "result": {
    "nodeId": 3
  }
}

Usage in Node.js

const result = await send('DOM.copyTo', {"nodeId": 1, "targetNodeId": "targetNodeId-value"});
console.log(result);
// {"nodeId": 3}