Frage

My goal is to add styles of wrappers to pictures. Styles are added by jquery ui and are placed in html in iframe:

<div class="wrapper style:"xyz">
  <img id="link1">
</div>

<div class="wrapper  style:"abc">
   <img id="link1">
</div>

<div class="wrapper  style:"wer">
  <img id="link1">
</div>

Here is my buggy code: I think I am using i right. images already has added id: link1 link2 link3 and so on.

var deleteWrapper = function () {
    var x = document.getElementById("preview");
    var y = (x.contentWindow || x.contentDocument);
    var imageWrappers = y.$(".ui-wrapper");
    imageWrappers.each(function( i ) {
     i= i+1;
    var wrapperStyle[i] = imageWrappers[i].attr('style');
    y.$('#link' + i ).attr('style', wrapperStyle[i]);
   });
}
War es hilfreich?

Lösung

Correct you html

example

<div class="wrapper" style="xyz">
  <img id="link1">
</div>

jQuery Code

$('div.wrapper').each(function(){
    $(this).find('img').attr('style',$(this).attr('style'));
});
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top