gpt4 book ai didi

javascript - Gif 图像未显示在 html 页面上

转载 作者:行者123 更新时间:2023-11-27 22:35:31 26 4
gpt4 key购买 nike

我有一个 html 页面,当它等待来自服务器的数据时,它应该显示一个动画 gif 图像以表明它正在等待。

这是代码:

 $("#display").append('<img src="/templates/image.gif alt="red" width="30" height="30" " />');

这是 html:

 <div style="margin:0 auto;" id="display"></div>

gif 动画取自 gif 生成器:http://www.ajaxload.info/并放入相关目录。

但在 Google chrome 中显示的只是一个“破损图片图标”,而在 Firefox 中则完全不显示任何内容。它似乎无法访问 .gif 文件,因为当我尝试从服务器访问文件时出现 404 错误。尽管我可以在工作区的目录中看到它。

我看不出问题是什么。

谢谢

最佳答案

Firefox 隐藏“损坏的图像”,Chrome/Internet Explorer 显示损坏的图像占位符。

好像你没有关闭 src 属性。

$("#display").append('<img src="/templates/image.gif alt="red" width="30" height="30" " />');

应该是

$("#display").append('<img src="/templates/image.gif" alt="red" width="30" height="30" />');

关于javascript - Gif 图像未显示在 html 页面上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14063385/

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