循环插件仅在存在
时才起作用。预定义的?
我有以下方法来进行照片幻灯片播放:
$('#Yeah').click(function() {
{% for photo in photos %}
$('#slideShow').append('<img src="/image?blob_key={{ photo }}" />');
% endfor %}
$('#slideShow').cycle({
fx: 'fade',
speed: 300,
next: '#slideShow',
timeout: 0
});
});
当 div 标签下有空的 img 标签时,幻灯片根本无法播放。
<div id="slideShow">
</div>
但是,如果我至少在 div 标签下添加一个 img 标签,它就可以使用相同的代码。
<div id="slideShow">
<img class="pics" width="200" height="200">
</div>
有谁知道有什么问题吗?任何帮助表示赞赏。
I have following to do the photo slideshow:
$('#Yeah').click(function() {
{% for photo in photos %}
$('#slideShow').append('<img src="/image?blob_key={{ photo }}" />');
% endfor %}
$('#slideShow').cycle({
fx: 'fade',
speed: 300,
next: '#slideShow',
timeout: 0
});
});
When I have empty img tag under the div tag, the slideshow won't work at all.
<div id="slideShow">
</div>
However, if I at least add one img tag under the div tag, it works with the same codes.
<div id="slideShow">
<img class="pics" width="200" height="200">
</div>
Does anyone have any clue what's the problem ? Any helps are appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为问题是在 Cycle 插件初始化之前图像没有完全加载。
查看“lite”版本的来源,我明白了:
因为您没有指定
width
和height
选项,所以它默认为![]()
元素的宽度和高度,当图像未完全加载时,这两个值都是 0。编辑:尝试:
编辑2:存在语法错误:
需要是:
I think that the problem is that the images are not fully loaded before the Cycle plugin is initialized.
Looking through the source of the "lite" version, I see:
Because you do not specify the
width
andheight
options, it defaults to the width and height of the<img>
element, which are both 0 when the image is not fully loaded.EDIT: Try:
EDIT2: There is a syntax error:
needs to be: