← Back to DOM domain

DOM.getAnchorElement

Returns the target anchor element of the given anchor query according to https://www.w3.org/TR/css-anchor-position-1/#target.

Domain: DOM experimental

Parameters

NameTypeDescription
nodeIdNodeIdId of the positioned element from which to find the anchor.
anchorSpecifier (optional)stringAn optional anchor specifier, as defined in https://www.w3.org/TR/css-anchor-position-1/#anchor-specifier. If not provided, it will return the implicit anchor element for the given positioned element.

Returns

NameTypeDescription
nodeIdNodeIdThe anchor element of the given anchor query.

Example Request

{
  "id": 1,
  "method": "DOM.getAnchorElement",
  "params": {
    "nodeId": 1
  }
}

Example Response

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

Usage in Node.js

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