gpt4 book ai didi

javascript - 图片未显示在页面上?使用 .append()

转载 作者:行者123 更新时间:2023-11-28 04:54:21 25 4
gpt4 key购买 nike

图像未显示在我的页面主体中。显示的只是一个空的图像框。控制台显示错误:

Failed to load resource: the server responded with a status of 404 (Not Found)

我的所有图像都位于名为 ProductImages 的文件夹中,因此我认为我没有使用正确的图像源,但仍然无法使其正常工作。

   $("#mainBody").append("<img src =" + imageFilename + ">"); 

最佳答案

设置图片src时,需要指定图片资源的有效路径。

如果图像位于名为 ProductImages 的目录下,该目录位于您网站的根目录下,请尝试以下操作:

$("#mainBody").append("<img src ="'/ProductImages/" + imageFilename + "'>"); 

关于javascript - 图片未显示在页面上?使用 .append(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42663719/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com