私はinitial.html別の html ページからロードしようとしています:
$("#hidden_demo_div").load("modules/another.html", function (data) {
var value = $(data).filter("#demo_div");
var html = value.html(); // THERE IS NO <strong>Hello</strong> here!!!
}
ここにanother.htmlからのスニペット
<html>
.........................
<head>
<script type="text/javascript">
$(document).ready(function() {
anotherMethodInvocation();
});
</script>
</head>
<div id="demo_div"></div>
</html>
次はanother.htmlの JS で私は持っています:
function anotherMethodInvocation() {
$("#demo_div").append("<strong>Hello</strong>");
}
問題は、(読み込み時のコールバック関数で) 静的な HTML だけを取得し、変更しないのはなぜですか?
更新 1:
a) 「#hidden_demo_div」はinitial.html (.load を含む JS コードがリンクされている HTML) にあります。この要素は BODY で宣言されています。
b)BODYに(1つのhtmlファイルに)入れても機能しません
<div id="hidden_demo_div"></div>
そして(別のhtmlファイルへ)
<div id="demo_div"></div>
で。