Can you please take a look at This Pen and let me know why I am getting wrong output ("iFrame is Empty") while the #this-frame is already populated with
$("#this-frame").contents().find("body").text("iFrame Lorem ...!");
and is not empty! Here is the code
<iframe id="this-frame"></iframe>
$(function() {
$("#this-frame").contents().find("body").text("iFrame Lorem ...!");
setTimeout(() => {
if ($("#this-frame").contents().find("body").length) {
console.log("iFrame is Empty");
} else {
console.log("iFrame is not Empty");
}
}, 500);
});