0

I have written my own js/jquery code for some of the content on my website. now same content is inside iframe but js/jquery only applied for content without iframe.

any way i can re use same code for both contents ?

example i want this to work for both

$( ".myclass-price-info" ).appendTo( $( ".myclass-single" ) );

Edit: example: i have this on my page as normal html

<div class="test"> This is test div </div>

Then i have same div inside iframe like below

<iframe src="">
   <html>
     <body>
     <div class="test"> This is test div </div>
     </body>
   </html>
</iframe>

this is only one div as an example i have full page with same example.

now i already wrote js/jquery to target my .test class and perform some js/jquery action. the js/jquery is working for normal html but not for iframe div. e.g i changed background of div its changed for normal html but not for div inside iframe.

1 Answers1

2

If it's not cross domain:

$('#iframeid').contents().find('.myclass-single').append('.myclass-price-info');
charlietfl
  • 170,828
  • 13
  • 121
  • 150
Rosy
  • 31
  • 4