Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get document object from a child element

People also ask

How do you select child elements in CSS?

The child combinator ( > ) is placed between two CSS selectors. It matches only those elements matched by the second selector that are the direct children of elements matched by the first. Elements matched by the second selector must be the immediate children of the elements matched by the first selector.


element.ownerDocument will give you a reference to the document to which any DOM element belongs.


Yes, the document object is the parent of the <HTML> element (at least in Firefox). Find it like this:

function FindDoc(el) {
    while(el.parentNode) {
        el = el.parentNode;
    }
    return el;
}