0

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]);
   });
}

1 Answer 1

1

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'));
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.