我有主要的HTML文档:
<html><head></head>
<body>
<div id="content">
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
另外我有一个内容文件(不是html文档,只是html代码):
<div class="CodeRay">
<div class="code"><pre><span class="no"> 1</span> require
....
</pre></div>
Run Code Online (Sandbox Code Playgroud)
我想将内容文件添加到html文档中,如下所示:
<html><head></head>
<body>
<div id="content">
<div class="CodeRay">
<div class="code"><pre><span class="no"> 1</span> require
....
</pre></div>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
如何使用jQuery来完成这项任务?此外,我需要运行这个网站localy.谢谢.
编辑:本地意味着像"file:/// E:/Work/ReadTheCode/main.html"
使用jQuery的.load()功能.代码可能看起来像这样:
$(document).ready(function(){
$('#content').load('contentFile.html');
});
Run Code Online (Sandbox Code Playgroud)