L84
L84

Reputation: 46308

Target iFrame Body Using jQuery (Same Domain)

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;?

Upvotes: 0

Views: 1203

Answers (1)

Matthew Blancarte
Matthew Blancarte

Reputation: 8301

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/

Upvotes: 1

Related Questions