How do I change the style of an element in an iframe from the parent page?

1

I use a component that generates a iframe by accessing a remote page.

Example: Assuming that in iframe there is a table with some TDs with class destaque , I want to put a red border in these "highlights".

I tried the following code, but it does not work:

$('iframe tr td.destaque').css('border-color', 'red');

How to change the style of an element in a iframe from the parent page?

UPDATE: Trying to use contents , as answered by @Rafalages, displays the following error:

  

jquery-3.1.0.min.js: 2 Uncaught SecurityError: Failed to read the 'contentDocument' property from 'HTMLIFrameElement': Blocked a frame with origin " link "from accessing a frame with origin" link ". Protocols, domains, and ports must match.

    
asked by anonymous 14.10.2016 / 01:17

1 answer

1

.contents () should resolve:

$('iframe').contents().find('tr td.destaque').css('border-color', 'red');

link

    
14.10.2016 / 03:25