Note that there are some explanatory texts on larger screens.

plurals
  1. POprependTo closest specified Parent div from an iframe
    text
    copied!<p>I'm trying to use JQuery from inside an <code>iframe</code> to <code>.prependTo</code> a <code>.class</code> <code>div</code> inside the Parent.</p> <p>This has multiples of the same .class. **EDIT And iframes</p> <p>Everything is on the same domain.</p> <p><strong>So, from inside the Main document:</strong></p> <pre><code>&lt;div class="NewPHOTOS"&gt; **&lt;!--PUT ME HERE!--&gt;** &lt;div class="LinePhoto"&gt; &lt;a href="images/518279f07efd5.gif" target="_blank"&gt; &lt;img src="images/thumb_518279f07efd5.gif" width="50" height="50"&gt; &lt;/a&gt; &lt;/div&gt; &lt;iframe class="uploadLineID_55" width="800px" height="25px" src="../../uploads/uploadiframe.php" scrolling="no" seamless&gt;&lt;/iframe&gt; &lt;/div&gt; </code></pre> <p><strong>Script inside the iframe</strong>:</p> <pre><code>$(document).on("click", '#TEST', function() { appendImagetoParent(); }); function appendImagetoParent() { var data = '&lt;div class="LinePhoto"&gt;&lt;a href="images/TEST.gif" target="_blank"&gt;&lt;img src="images/thumb_TEST.gif" width="50" height="50"&gt;&lt;/a&gt;&lt;/div&gt;'; $(".NewPHOTOS", window.parent.document).each(function() { $(data).prependTo($(".NewPHOTOS")); }); /* $(data).prependTo( $(".NewPHOTOS", window.parent.document) ); This prepends to Every .NewPHOTOS */} </code></pre> <p>I've been running around in circles and googleing for hours now. I can't figure this out.</p> <p>What am I doing wrong here?</p> <p><strong>EDIT</strong> I used, works great!</p> <pre><code> $(parent.document).find('.' + frameElement.className ) .closest('.NewPHOTOS') .prepend( data ); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload