0

I am trying to target the body of an iFrame with jQuery and it isn't working.

Here is the code:

HTML

<div class="editor">
  <iframe id="editorf">
    <body>
    </body>
  </iframe>
</div>

JS

$(function() {
   $('#editorf').contents().find('body').css( " background-color", "none" );
});

The iFrame is located on the same domain but it is one generate by my CMS so I do not have access to it directly. How do I target the body of the iFrame and apply the css background-color:none;?

3
  • Any errors in your console? It's possible that you may be trying to access the contents before they are loaded... Nov 27, 2013 at 5:13
  • @MatthewBlancarte - No errors are generated.
    – L84
    Nov 27, 2013 at 5:19
  • Not sure if it will make the difference, but you could try removing that extra space within the background-color string. Nov 27, 2013 at 5:28

1 Answer 1

1

Looks like you have an extra space in your css property string.

" background-color", "none"

Should be

"background-color", "none" 

Working demo: http://jsfiddle.net/X8wDX/1/

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.