<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<iframe src="demo.html" id="myFrame" name="myFrame" frameborder="0"></iframe>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script>
$(function(){
console.log($('#myFrame').contents().find('#btn').text());
})
</script>
</body>
</html>
要放在localhost下面使用
转载于:https://blog.51cto.com/smilezhuolin/1369046