Namespace: Elements:getTextContent

Elements:getTextContent

Methods

getTextContent(target, onlyFirstLevelopt, nullable) → {String}

Return the de-nodified text content of a node-ridden string or a DOM-node. Returns the raw text content, with all markup cleanly removed. Can also be used to return only the concatenated child text nodes.

Parameters:
Name Type Attributes Default Description
target String | Node

the node-ridden string or DOM-node to "clean"

onlyFirstLevel Boolean <optional>
<nullable>
false

true if only the text of direct child text nodes is to be returned

Source:
Throws:

error if target is neither markup nor node

Returns:
the text content of the provided markup or node
Type
String
Example
someElement.textContent = getTextContent('<p onlick="destroyWorld();">red button <a>meow<span>woof</span></a></p>');