user1919
user1919

Reputation: 3938

Get the content of iframe which generated on the fly

I have an iframe which is generated on the fly and appended in a div like this:

content.innerHTML = '<iframe src="' + url + '" id="id_iframe" style="border:0px #BD8D46 dotted;" scrolling="auto" frameborder="no" align="center"></iframe>';

The div which is appended in invisible (display: none;)

What I want to do is to change the display of the div according to the content of the iframe.

I try this

console.log($("#id_iframe").contents());

But I get nothing back. No contents. When I use the developers tools I see that the iframe exists in the DOM.

Is it possible to get the iframe content on the fly?

Upvotes: 0

Views: 40

Answers (1)

splitiii
splitiii

Reputation: 209

$("#id") can not select dom elemets that where added after dom load

$("document").find("#id_iframe").contents()

Upvotes: 1

Related Questions