Questions like this and this say using jQuery contents()
lets you access an iFrame element.
However, this code isn't working.
It isn't an cross-origin issue as both parent and iFrame are hosted on the Codepen.io domain.
If you view the Codepen, you can see the iFrame has a child SVG element called designBox
.
$(document).ready(function() {
$("#livePreview").on("load", function() {
var designBox = $("#livePreview").contents().find("#designBox");
var livePreviewContents = $("#livePreview").contents();
console.log("Loaded live preview. Design box: " + designBox.length + ". Live preview contents: " + livePreviewContents);
});
});