Reputation: 1438
I want to change the Body bgcolor inside iframe. This is my iframe
console.log(iframe)
I used this code
$(iframe.id).contents().find('body').css({'background-color' : 'transparent'});
it is adding transparent inside the style but i want to change bgcolor:#ffffff to transparent. See the attached image below.
Upvotes: 0
Views: 1592
Reputation: 7853
You may just doing this :
$('iframe').contents().find('body').css({'background-color' : 'transparent'});
If it doesn't work, try that :
$('iframe').contents().find('body').css({'background-color' : 'inherit'});
$('iframe').contents()
gets the content of the iframe, then you can change the backgroud of the body
EDIT :
So, following the comments, to remove the bgcolor
attribute and add the transparent
background, do that :
$('iframe').contents().find('body').css({'background-color' : 'transparent'}).removeAttr('bgcolor');
Upvotes: 3