您的位置:首页 > Web前端 > JQuery

jquery取得父页面元素

2014-03-05 11:47 239 查看

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);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: