1

I have a div with id "test". Inside it is an iframe which has no id. I need to access the body contents of this iframe. How to do it using JS/Jquery?

Bhumi Singhal
  • 8,063
  • 10
  • 50
  • 76

2 Answers2

1

Access it like this:

$('#test>iframe').contents.find('body') // This will get you body tag 
Mischa
  • 42,876
  • 8
  • 99
  • 111
Ashirvad
  • 2,367
  • 1
  • 16
  • 20
0

jquery will do it.

 var objiframe=$('#test').find('iframe');

you'll get iframe in objiframe

then use objiframe with selector to get or set attribute and contents of iframe.

Milind Anantwar
  • 81,290
  • 25
  • 94
  • 125