A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://webplatform.github.io/docs/dom/Node/textContent below:

textContent ยท WebPlatform Docs

textContent Summary

Sets or retrieves the text content of a node and any child nodes.

Property of dom/Nodedom/Node

Syntax
var textContent = node.textContent;
node.textContent = newText;
Return Value

Returns an object of type StringString

The text content of a node and its child nodes, if any.

Examples
// Given the following HTML fragment:
//   <div id="divA">This is some text</div>

// Get the text content:
var text = document.getElementById("divA").textContent;
//

The following example displays the textContent property of a <script> tag.

<!DOCTYPE html>
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script id="scrtest" type="text/javascript">
function gettextContent(el){
alert(el.textContent);
}
</script>
<title>textContent example</title>
</head>

<body>
<script type="text/javascript">
gettextContent(document.getElementById('scrtest'));
</script>



</body></html>
Notes

textContent returns null if the element is a document, a document type, or a notation. To grab all of the text and CDATA data for the whole document, one could use document.documentElement.textContent.

If the node is a CDATA section, a comment, a processing instruction, or a text node, textContent returns the text inside this node (the nodeValue).

For other node types, textContent returns the concatenation of the textContent attribute value of every child node, excluding comments and processing instruction nodes. This is an empty string if the node has no children.

Setting this property on a node removes all of its children and replaces them with a single text node with the given value.

Related specifications
DOM Level 3 Core
Recommendation
Attributions

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4