I have a page which contains an iframe to another page, what I am looking for is to click something inside the iframe, which can then access or more specifically hide a div in the parent. I know some JQuery but for some reason just sit there blankly at the code editor when I try to write it on my own
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
try this in iframe:
$('#DIVtobehidden', window.parent.document).hide();
回答2:
$("#element-In-Iframe").on('click', function() {
$('#element-in-parent-window', window.parent.document).hide();
});
FIDDLE
回答3:
If both pages are on the same (sub)domain you should be able to access the parent window with:
window.parent.document.getElementById('divId')
Well this is without jQuery but should work