【发布时间】:2013-04-02 20:52:13
【问题描述】:
我有大量内容图片。这就是我决定使用延迟加载的原因:http://www.appelsiini.net/projects/lazyload
我的页面是这个:http://www.mysecretathens.gr/kulte_test/osterman.html
我遵循了所有必需的说明,但不明白为什么我想测试延迟加载功能的第一张图片不显示
在我的头部是这样的:
<script src="jquery.js" type="text/javascript"></script>
<script src="lazyload.js" type="text/javascript"></script>
图片:
<img class="lazy" src="grey.gif" data-original="osterman/ost21.jpg" width="900" height="602" >
和JS代码
<script type="text/javascript">
$("img.lazy").lazyload();
</script>
为什么只显示 gray.gif 而不是实际图像?有任何想法吗?我有错误的 jquery 文件吗?提前致谢
【问题讨论】:
-
你用的是什么浏览器?
-
@PhilipBevan Chrome,为什么?
-
chrome 调试器显示错误:Uncaught SyntaxError: Unexpected identifier jquery.js:9598 Uncaught SyntaxError: Unexpected identifierlazyload.js:228 Uncaught ReferenceError: $ is not defined osterman.html:205 这表明您的实现是不正确。尝试再次查看下载文件。尝试使用 //ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js 作为您的 jquery src
-
并尝试使用 cdnjs.cloudflare.com/ajax/libs/jquery.lazyload/1.8.4/… 作为您的延迟加载源。完成后下载这两个文件,如果工作并使用它们。
-
太棒了! @PhilipBevan 现在可以使用了
标签: javascript jquery html lazy-loading