I declare:
var iframe = document.createElement("iframe");
now I want to use this var iframe in order to apply jQuery methods:
$("iframe").on("load", function () {
// DO SOMETHING
});
Like this does not work. How must I reference my iframevar
UPDATE: I CAN NOT change the iframe declaration method.
You need to put the element in the document before you can select it using
$("iframe"):Nevertheless, a handler can be added to an element before you put it in the DOM (which you will have to do sooner or later). You just need to pass the actual DOMElement stored in
iframeto$, instead of a selector string: