ownerDocument

In this chapter you will learn:

  1. How to get the reference to entire document

ownerDocument property

The ownerDocument property is a pointer to the document node that represents the entire document.

<!DOCTYPE html><!-- j  a v  a  2  s  .co m-->
<html>
    <body>
        <div id="div1">
            <p>Hello <b>World!</b></p>
            <ul>
                <li>List item 1</li>
                <li>List item 2</li>
                <li>List item 3</li>
            </ul>
        </div>
        <p>Hello <b>World!</b></p>
        <script type="text/javascript">
               var div = document.getElementById("div1");
               var node = div.ownerDocument;
               document.writeln(node); 
        </script>
        
    </body>
</html>

Click to view the demo

Next chapter...

What you will learn in the next chapter:

  1. How to remove a node from another node
  2. How to remove the last node from its parent
Home » Javascript Tutorial » DOM
Document Object Model
Node Type
nodeName and nodeValue
childNodes
parentNode
previousSibling and nextSibling
lastChild and firstChild
appendChild
insertBefore
ownerDocument
removeChild
replaceChild
Text
NodeList Length
DOM classes