JavaScript Reference/Javascript Objects/TextNode

Материал из Web эксперт
Перейти к: навигация, поиск

"TextNode" Example

    
<html>
<head>
<script>
function replaceText(){
    var myTextNode = document.createTextNode("Text was replaced");
    var newTN = replaceMe.firstChild.replaceNode(myTextNode); 
} 
</script>
</head>
<p id="replaceMe">This is some text that will be replaced</p>
<button onclick="replaceText();">Replace text</button>
</body>
</html>



"TextNode" JavaScript Methods

+----------------+--------------------------------------------------------------+
| JavaScript     |appendData                      deleteData                    |
| Methods        |insertData                      replaceData                   |
|                |splitText                       substringData                 |
+----------------+--------------------------------------------------------------+



"TextNode" JavaScript Properties

+----------------+--------------------------------------------------------------+
| JavaScript     |data                            length                        |
| Properties     |nextSibling                     nodeName                      |
|                |nodeType                        nodeValue                     |
|                |parentNode                      previousSibling               |
+----------------+--------------------------------------------------------------+



"TextNode" Syntax and Note

Note:
Access to a text node created using the createTextNode() method.
    
Syntax:
    
textNodeName = document.createTextNode("value")
textNodeName.memberName