HBCMS更多的中文手册参考:

parentElement Method

DHTML文档教程

Retrieves the parent element for the given text range.

dhtml语法

oElement = TextRange.parentElement()

Return Value

Returns the parent element object爄f successful, or null otherwise.

Remarks

The parent element is the element that completely encloses the text in the range.

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 in the parent element rather than in any of the contained elements.

This feature might not be available on non-Microsoft® Win32® platforms.

DHTML代码范例

This example uses the parentElement method to retrieve the parent element for the text range created from the current selection, and display the tag name of the element.

<SCRIPT LANGUAGE="JScript">
var sel = document.selection;
var rng = sel.createRange();
var el = rng.parentElement();
alert(el.tagName);
</SCRIPT>

是否符合公共标准

There is no public standard that applies to this method.

Applies To

TextRange