access div in iframe parent

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

Answers


try this in iframe:

$('#DIVtobehidden', window.parent.document).hide();

$("#element-In-Iframe").on('click', function() {
    $('#element-in-parent-window', window.parent.document).hide();
});

FIDDLE


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


Need Your Help

Initialize NSArray with floats?

objective-c cocoa

Is this a valid way to initalize an NSArray with float objects?

Find Java classes implementing an interface

java interface

Some time ago, I came across a piece of code, that used some piece of standard Java functionality to locate the classes that implemented a given interface. I know the functions were hidden in some ...