Answer the question
In order to leave comments, you need to log in
How to reach with jQuery to an element inside a frame?
treeview.html frame file:
<!DOCTYPE HTML >
<html>
<head>
<title></title>
</head>
<body>
<div id="tree">123</div>
</body>
</html>
<!DOCTYPE HTML >
<html>
<head>
<script type="text/javascript" src="src/js/jquery-1.11.3.min.js"></script>
<script type="text/javascript">
$(function main() {
//alert(1);
alert($("#treeview").contents().find("#tree").text());
});
</script>
</head>
<iframe src="treeview.html" id="treeview" name="treeview">
</iframe>
</html>
Answer the question
In order to leave comments, you need to log in
var iframe = document.querySelector('#treeview');
var iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
var tree = iframeDocument.getElementById('tree');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question