← Back to DOM domain

DOM.getNodesForSubtreeByStyle

Finds nodes with a given computed style in a subtree.

Domain: DOM experimental

Parameters

NameTypeDescription
nodeIdNodeIdNode ID pointing to the root of a subtree.
computedStylesarrayThe style to filter nodes by (includes nodes if any of properties matches).
pierce (optional)booleanWhether or not iframes and shadow roots in the same target should be traversed when returning the results (default is false).

Returns

NameTypeDescription
nodeIdsarrayResulting nodes.

Example Request

{
  "id": 1,
  "method": "DOM.getNodesForSubtreeByStyle",
  "params": {
    "nodeId": 1,
    "computedStyles": []
  }
}

Example Response

{
  "id": 1,
  "result": {
    "nodeIds": [
      3,
      4,
      5
    ]
  }
}

Usage in Node.js

const result = await send('DOM.getNodesForSubtreeByStyle', {"nodeId": 1, "computedStyles": []});
console.log(result);
// {"nodeIds": [3, 4, 5]}