How to apply css style to iframe content?

I am trying to apply CSS style for content inside iframe, check this link http://jsfiddle.net/pPqGe/

JQuery

$(document).ready(function() { $('iframe').contents().find('h1').css('color','red'); }); 

HTML:

 <iframe src="mysite" width="100%" height="100%" id="myframe"></iframe> 

For the iframe source, I used the website live.

+4
source share
1 answer

It works. The problem is that there is no H1, only H2. Check out this link http://jsfiddle.net/pPqGe/1545/ .

HTML:

 <iframe src='jsfiddle.net'></iframe> 

JavaScript:

 $(document).ready(function() { $('iframe').contents().find('h2').css('color','red'); $('iframe').contents().find('#header').css('opacity','.2'); }); 
+5
source

All Articles