Programming Tips - jQuery: access the DOM in parent of an iframe

Date: 2024mar8 Library: jQuery Language: javaScript Q. jQuery: access the DOM in parent of an iframe A. From the iframe:
$(window.parent.document).find('#myelement).css('background-color','red');
This is just example you can do whatever you want. How it works: window.parent is the parent window of the current window (plain javaScript) window.parent.document is its document (plain javaScript) $(window.parent.document) converts it into jQuery .find('#myelement) is a normal jQuery query .css('background-color','red) changes the background color of id=myelement to red (an example)