我试图加载从initial.html不同的HTML页面与另一页:负载与DOM改变
$("#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>
下一个片段在JS为another.html我有:
function anotherMethodInvocation() {
$("#demo_div").append("<strong>Hello</strong>");
}
所以问题是为什么我得到(在我的负载回调函数)只是静态的HTML,但没有改变?
UPDATE 1:
一) “#hidden_demo_div” 位于initial.html(HTML其中具有.load JS代码链接)。 这个元素是在BODY声明:
B)如果我把在BODY (一个HTML文件,它甚至不工作)
<div id="hidden_demo_div"></div>
和 (到另一个HTML文件)
<div id="demo_div"></div>
在身体。
你没有头部后** **
标签。 – Bruno你的结构看起来如何?我的意思是你的文件和这个方法在哪里运行? –
请提供一些关于具有anotherMethodInvocation()的JS的更多信息。它是否在索引html或another.html中链接? – roncsak