【发布时间】:2015-11-19 17:35:15
【问题描述】:
我有两个文件 index.html 和 index2.html。这两个文件都在本地机器上的同一目录中(无法访问 PHP 等)。
我正在尝试
<title>Page Title</title>
从 index.html 并使用 jQuery 将其插入到 index2.html 中的 div.content 中。在 index2.html 我有:
$('.content').load("index.html title");
我尝试使用 jQuery .load() 但它不起作用,我看到 documentation 状态:
"jQuery 使用浏览器的 .innerHTML 属性解析检索到的文档并将其插入到当前文档中。在此过程中,浏览器通常会从文档中过滤出 、
如何从 index.html 中检索标题并使用 jQuery 将其放在 index2.html 中的 div.content 中?
【问题讨论】:
-
你的控制台有什么错误吗?
.load()方法实际上是在检索页面吗? -
控制台中没有错误,我能够将 index.html 的其他部分加载到 index2.html 中,例如
$('.content').load("index.html #header");
标签: javascript jquery html frontend