Reputation: 7971
I am using jQuery .contents() method to change class under iframe but it is not wokring. When i am giving direct in iframe source then it is working fine but when i generating path it is not working
$('.viewMe').click(function (){
var url= 'viewpage.html'
$('#myframe').attr('src',url).animate({height:1000},1000,
function (){$('.Close').fadeIn(1500)});
$('body').height($(window).height()).css('overflow','hidden');
var $c = $('#myframe').contents();
$c.find('.inner-wp').css('margin','0')
});
Upvotes: 2
Views: 11819
Reputation: 663
from https://forum.jquery.com/topic/not-working-content-method-of-iframe
"it only works when both the iframe and the page come from the same domain. And it only works after the iframe is actually loaded."
Upvotes: 1
Reputation: 31920
You have to call it on iframe load
event like this:
$("#myframe").load(function() {
var $c = $('#myframe').contents();
$c.find('.inner-wp').css('margin', '0');
});
Upvotes: 3