0

每当我使用 .load() 函数将页面加载到 div 时,它只返回文本而不是背景图像或页面中的任何图像。

索引.html

<html>
<title> web page </title>
<body>
<div id="Content" >
</div>
<script type="text/javascript" src="jquery.js" ></script>
<script type="text/javascript" src="jquery.min.js" ></script>
</body
</html>

page.html (将加载到 div id="Content" 的页面)

<html>
<title> web page </title>
<body>
<div>
<h1> WELCOME TO THIS LOADED PAGE </h1>
<img src="image.jpg" />
</div>
<script type="text/javascript" src="jquery.js" ></script>
<script type="text/javascript" src="jquery.min.js" ></script>
</body
</html>

jQuery.js $(document).ready(function(){ $('#content').load('page.html'); });

它最终只显示WELCOME TO THIS LOADED PAGE,但不显示page.html中包含的图像。

谢谢你。

4

1 回答 1

0

如果它没有在页面上显示任何图像,则您可能没有指向存储图像的正确位置。图像是否位于另一个目录中?

<img src="image.jpg" />

可能需要是这样的:

<img src="./images/image.jpg" />

于 2013-01-04T21:15:44.997 回答