jquery取得父页面元素方法。
有时候要去修改或取得父页面的元素,直接用id是取不到的,
方法哪下:
取父窗口的元素方法:$(selector, window.parent.document);
取父窗口的父窗口的元素就可以用:$(selector,window.parent.parent.document);
类似的,取其它窗口的方法大同小异
$(selector, window.top.document);
$(selector, window.opener.document);
$(selector, window.top.frames[0].document);
用什么根据0实际情况了,frame或iframe是window.top.document. 包含的子页面,或弹出的子页面,则用window.parent.document。
selector则可根据实际确定了,一般id最好,
例:$('#useremCount_MyMessage', window.top.document);
有时候要去修改或取得父页面的元素,直接用id是取不到的,
方法哪下:
取父窗口的元素方法:$(selector, window.parent.document);
取父窗口的父窗口的元素就可以用:$(selector,window.parent.parent.document);
类似的,取其它窗口的方法大同小异
$(selector, window.top.document);
$(selector, window.opener.document);
$(selector, window.top.frames[0].document);
用什么根据0实际情况了,frame或iframe是window.top.document. 包含的子页面,或弹出的子页面,则用window.parent.document。
selector则可根据实际确定了,一般id最好,
例:$('#useremCount_MyMessage', window.top.document);
本文介绍了使用jQuery获取父页面及更深层次页面元素的方法,包括如何通过不同的window对象获取不同层级的页面元素。

被折叠的 条评论
为什么被折叠?



