You are here: Reference > JavaScript > client-side > HTML DOM > properties > parentTextEdit

parentTextEdit property

Browser support:
Returns the closest ancestor element of the current element in the DOM hierarchy that can be used to create a TextRange object.
A call to the createTextRange method on the returned element creates a TextRange object that contains the current element.

Syntax:

object.parentTextEdit;
You can find the related objects in the Supported by objects section below.
This property is read-only.

Possible values:

Returns the object that can be used to create a TextRange object.
Default: this property has no default value.

Example HTML code 1:

This example illustrates the use of the parentTextEdit property:
<head>
    <script type="text/javascript">
        function CreateParentRange (elem) {
            //gets the first object that can be used to create a TextRange object
            var textRangeObj = elem.parentTextEdit ;

            // alert with the tagName of the object
            alert (textRangeObj.tagName);

            // create the TextRange
            var myTextRange = textRangeObj.createTextRange ();

            // select all contents in the TextRange
            myTextRange.select ();
        }
    </script>
</head>
<body>
    <div onclick="CreateParentRange (this)">Click this text to create a textRange from this division element!</div>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content