<button id="btn"></button>
<div id="iframeDecl">
<iframe src="" name="iframeHtml" id="iframeHtml"></iframe>
</div>
js:
$(function(){
$("-sharpbtn").click(function(){
$("-sharpiframeHtml").attr("src","https://baidu.cn");
$("-sharpiframeHtml").width($(window).width());
$("-sharpiframeHtml").height($(window).height());
var iframeDocument = $("-sharpiframeHtml")[0].contentDocument;
$(iframeDocument ).ready(function(){
alert("111");
console.log($(this).find("-sharpbanner"))
$(this).find("-sharpbanner").click(function(){
alert("....");
});
})
})
});
I want to implement a function, click the button on the local page, then introduce an external page through iframe, and then bind events to the dom elements in the external page.