Reputation: 888
I have to apply CSS to an <iframe>
present in my HTML page using jQuery. The CSS must only be applied to that <iframe>
and not the other parts of the HTML. Can anyone help me to do it using jQuery?
Upvotes: 1
Views: 513
Reputation: 2102
The best way to do it using just css is to access the iFrame with an id, like this:
$('#iframe-unique-name').children().css('background-color', 'red');
This would set the background color of the elements contained within the iframe to red, for example.
Upvotes: 1
Reputation: 490233
If the iframe
's URL (src
attribute) don't violate the same domain policy, you should be able to...
$('iframe').contents().find('body').css({ fontSize: '130%' });
And if it doesn't, it will be on your domain. Can you just put the CSS there in the iframe
's source?
Upvotes: 1