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

deleteData method (comment, CommentNode, TextNode)

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

Syntax:

object.deleteData (start, removeCharNum);
You can find the related objects in the Supported by objects section below.

Parameters:

start
Required. Integer that specifies the start position of the contents to remove.
removeCharNum
Required. Integer that specifies the number of characters to remove.

Return value:

This method has no return value.

Example HTML code 1:

This example illustrates the use of the deleteData method:
<head>
    <script type="text/javascript">
        function RemoveText () {
            var textContainer = document.getElementById ("textContainer");
            var firstTextNode = textContainer.firstChild;
            firstTextNode.deleteData (0, 2);
        }
    </script>
</head>
<body>
    <div id="textContainer">The first two characters will be removed from this text.</div>
    <br /><br />
    <button onclick="RemoveText ()">Remove the first two characters from 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