JavaScript Reference/Javascript Methods/parentElement

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

"parentElement()" Example

   <source lang="javascript">
   

<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>


     </source>
   
  


"parentElement()" is applied to

   <source lang="javascript">

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

     </source>
   
  


"parentElement()" Syntax, Parameters and Note

   <source lang="javascript">

Note: Returns a reference to the parent node of the text range.

Syntax:

textRangeName.parentElement()


     </source>