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
  • 7,883
  • 10
  • 49
  • 72

2 Answers2

1

Access it like this:

$('#test>iframe').contents.find('body') // This will get you body tag 
Mischa
  • 42,226
  • 8
  • 97
  • 109
Ashirvad
  • 2,377
  • 1
  • 13
  • 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
  • 79,642
  • 23
  • 92
  • 120