← Back to DOM domain

DOM.moveTo

Moves node into the new container, places it before the given anchor.

Domain: DOM stable

Parameters

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

Returns

NameTypeDescription
nodeIdNodeIdNew id of the moved node.

Example Request

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

Example Response

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

Usage in Node.js

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