I am trying to add some text into an iframe in my code but for some reason I can’t get the jquery to find a specific class in the frame. if I use a generic element like ‘body’ it works but I need to be able to reach the class ‘.shopify-buy__product__actual-price’.
This code works:
jQuery(document).ready(function( $ ){
var iframeDOM = $('iframe').contents();
var node = iframeDOM.find('body').html('<p>Starting at</p>');
});
But this does not:
jQuery(document).ready(function( $ ){
var iframeDOM = $('iframe').contents();
var node = iframeDOM.find('.shopify-buy__product__actual-price').html('<p>Starting at</p>');
});
Can someone explain how I can reach that class?
2
Answers
You need to let the iframe load before accessing elements
Try
You could try this: