Bhumi Singhal
Bhumi Singhal

Reputation: 8307

Access an iframe with no id which is inside a div(div has id)

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?

Upvotes: 1

Views: 5926

Answers (2)

Ashirvad
Ashirvad

Reputation: 2377

Access it like this:

$('#test>iframe').contents.find('body') // This will get you body tag 

Upvotes: 1

Milind Anantwar
Milind Anantwar

Reputation: 82241

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.

Upvotes: 0

Related Questions