我已经让它更早地工作了,但由于某种原因它不再工作了。有人可以解释一下为什么现在这行不通吗?
包含 iframe 的第一页:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>Test 1</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<div id="thediv" style="background: #ffff00;"> div </div>
<iframe id="theframe" src="test2.html"></iframe>
</body>
</html>
iframe 内容
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>test 2</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function () {
$("#clickme").click(function(){
$("#thediv", top.document).css("background","#ff0000");
alert($("#thediv", top.document).text());
});
});
</script>
</head>
<body>
<a href="#" id="clickme">clickme</a>
</body>
</html>