JavaScript Reference/Javascript Methods/parentElement

Материал из Web эксперт
Перейти к: навигация, поиск

"parentElement()" Example

    
<html>
<body>
<script language="JavaScript">
function function1() {
    var myRange = document.selection.createRange();
    var m = myRange.parentElement();
    m.innerText = "ParentElement"; 
} 
</script>
<input id="myB" type="button" value="Click me" onclick="function1();">
</body>
</html>



"parentElement()" is applied to

+----------------+--------------------------------------------------------------+
| Applied_To     |TextRange                                                     |
+----------------+--------------------------------------------------------------+



"parentElement()" Syntax, Parameters and Note

Note:
Returns a reference to the parent node of the text range.
    
Syntax:
    
textRangeName.parentElement()