Contents Index Topic Contents | ||
Previous Topic: open Next Topic: pasteHTML |
parentElement
Description
Retrieves the parent element for the given text range. The parent element is the element that completely encloses the text in the range.
Syntax
element = object.parentElement( )
Return Value
Returns an element object if successful, or null otherwise.
Remarks
If the text range spans text in more than one element, this method returns the smallest element that encloses all the elements. When you insert text into a range that spans multiple elements, the text is placed within the parent element rather than in any of the contained elements.
Remarks
This feature might not be available on non-Win32 platforms. See article Q172976 in the Microsoft Knowledge Base for the latest information on Internet Explorer cross-platform compatibility.
Example
The following JScript example retrieves the parent element for the text range created from the current selection and displays the tag name of the element.
var sel = document.selection; var rng = sel.createRange(); var el = rng.parentElement(); alert(el.tagName);Applies To
Top of Page
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.