I have used JQuery to load a website, like this:
$("#external-site")
.html('<object class="website" data="http://www.example.com'"><object/>');
into the #external-site
div. This puts an <object>
into the #external-site
div and inside that is a html document which looks like this: #document
. I want to attach an on click event to an element in the document. I have tried things like this:
$( ".myDiv" ).on( "click", function() {
console.log("hello")
});
Then, I tried a delegated event:
$( "#document" ).on( "click", ".myDiv", function() {
console.log("hello")
});
But neither would log to the console when I click on the .myDiv
element. Am I referencing the #document
correctly? Is it possible what I am trying to do?