Gets the number of characters in a text node.
Property of dom/CharacterDatadom/CharacterData
SyntaxNote: This property is read-only.
var textLength = textualNode.length;
Return Value
Returns an object of type NumberNumber
The number of characters in the node.
Examples
var phrase = document.createTextNode ("A flawed plan today is better than a perfect plan tomorrow.");
alert(phrase.length);
This example uses the length property to specify where a Text node is split by using the splitText method.
<script>
function fnChangeValue(){
var oListItem = document.createElement("LI");
var oList = document.getElementById("oList");
oList.appendChild(oListItem);
var oNode = oList.firstChild.childNodes(0);
var oTextNode = oList.firstChild.childNodes(0);
var oSplit = oTextNode.splitText(oTextNode.length/2);
oListItem.appendChild(oSplit);
}
</script>
<ul id="oList" onclick="fnChangeValue()">
<li>Start Here</li>
</ul>
Related specifications
Microsoft Developer Network: [Windows Internet Explorer API reference Article]
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