开发者

Get document object from a child element

Let's assume I have a jQuery object of a DIV element in body. I'd like to 开发者_开发问答obtain document object by traversing. Can it be possible ?

Note: window.document is not a option in my case.

Thank you.


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


firstElementChild The first child that is an element node Traversal module.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜