You are here: Reference > JavaScript > client-side > HTML DOM > methods > appendData (comment, CommentNode, TextNode)

appendData method (comment, CommentNode, TextNode)

Browser support:
Appends the specified text content to the end of the current TextNode, CommentNode or comment element.
The deleteData, insertData and replaceData methods and the data property can also be used to manipulate the text content of the current element.

Syntax:

object.appendData (stringToInsert);
You can find the related objects in the Supported by objects section below.

Parameters:

stringToInsert
Required. String that specifies the text to insert.

Return value:

This method has no return value.

Example HTML code 1:

This example illustrates the use of the appendData method.
<head>
    <script type="text/javascript">
        function AppendText () {
            var textContainer = document.getElementById ("textContainer");
            var firstTextNode = textContainer.firstChild;
            firstTextNode.appendData ("appended text ");
        }
    </script>
</head>
<body>
    <div id="textContainer">Text will be appended to the end of this text.</div>
    <br /><br />
    <button onclick="AppendText ()">Append some text to the end of the text above!</button>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content