有人可以就如何使其发挥作用给我建议吗?
<html>
<head>
<script src="../js/jquery-1.9.1.js"></script>
</head>
<body>
<div id="divpage"></div>
<script>
$("#divpage").load("http://localhost:3000/annotation/testuser/demo.html");
alert( "Load was performed." );
</script>
</body>
</html>
答案 0 :(得分:2)
浏览器必须加载完整的DOM,然后才能用javascript操作它,
在Jquery中使用.ready()
$(document).ready(function()
{
$("#divpage").load("http://localhost:3000/annotation/testuser/demo.html");
});
答案 1 :(得分:0)
将脚本块移出正文并向上移动到头部。然后,像这样包装你的JQuery:
<script>
$(document).ready(function()
{
$("#divpage").load("http://localhost:3000/annotation/testuser/demo.html");
alert( "Load was performed." );
});
</script>