1

I am trying to remove the class box-content but i can't target it... I've tried doing this $(".box-content").remove(); I even added a console log, to tell me when it is removed. Jquery is loaded proberly, getting no errors in console.

This is the full path enter image description here

What am i doing wrong?

UnscopeTying
  • 73
  • 1
  • 8
  • Possible duplicate of [jQuery/JavaScript: accessing contents of an iframe](https://stackoverflow.com/questions/364952/jquery-javascript-accessing-contents-of-an-iframe) – Turnip Feb 12 '19 at 17:18

3 Answers3

3

You cannot alter contents of an iframe that are loaded from a different domain. This is a restriction in place by browser security.

soccer7
  • 3,547
  • 3
  • 29
  • 50
  • So this will not be possible to delete the div containing .box-content? – UnscopeTying Feb 12 '19 at 17:26
  • Absolutely right. You are violating same origin policy by doing so which is not allowed. BUT, if you are on same domain as iframe location, you can do it no problem – soccer7 Feb 12 '19 at 17:28
0
$("#GAReviewsFrame").contents().find(".box-content").removeClass(".box-content');
Santhosh Kumar
  • 543
  • 8
  • 22
0

You need to use the contents method to get an element of an iframe, like this:

$("#GAReviewsFrame").contents().find("#box-content").remove();

Reference and examples:

https://api.jquery.com/contents/