javascript - prependTo closest specified Parent div from an iframe -


i'm trying use jquery inside iframe .prependto .class div inside parent.

this has multiples of same .class. **edit , iframes

everything on same domain.

so, inside main document:

<div class="newphotos">     **<!--put me here!-->**     <div class="linephoto">         <a href="images/518279f07efd5.gif" target="_blank">             <img src="images/thumb_518279f07efd5.gif" width="50" height="50">         </a>     </div>     <iframe class="uploadlineid_55" width="800px" height="25px" src="../../uploads/uploadiframe.php" scrolling="no" seamless></iframe> </div> 

script inside iframe:

$(document).on("click", '#test', function() {    appendimagetoparent();  });   function appendimagetoparent()  {  var data = '<div class="linephoto"><a href="images/test.gif" target="_blank"><img src="images/thumb_test.gif" width="50" height="50"></a></div>';  $(".newphotos", window.parent.document).each(function() { $(data).prependto($(".newphotos")); });  /* $(data).prependto( $(".newphotos", window.parent.document) ); prepends every .newphotos */} 

i've been running around in circles , googleing hours now. can't figure out.

what doing wrong here?

edit used, works great!

 $(parent.document).find('.' + frameelement.classname )                       .closest('.newphotos')                       .prepend( data ); 

$(document).on("click", '#test', appendimagetoparent);  function appendimagetoparent()  {      var div = $('<div />', {'class':'linephoto'}),           = $('<a />',   {href:'images/test.gif', target:'_blank'}),         img = $('<img />', {src:'images/thumb_test.gif', width:'50', height:'50'});      $(parent.document).find('.' + frameelement.classname )                       .closest('.newphotos')                       .prepend( div.append( a.append(img) ) ); } 

get class of containing iframe frameelement.classname, , use class find right iframe in parent document, find closest .newphotos element, , prepend content, created in more jquery'ish way.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -