我正在尝试设置jquery cycle2以逐步加载一组图像。页面上有多个“.slider”对象需要逐步加载图像


这是HTML



< li class =”slider“>< img title =”公司名称“alt =”公司名称“src =”/ photos / listings / company-name6.jpg“>
< script class =”other-slides“type =”text / cycle“ > [< img title ='Ad 6 Auto wide'alt ='Ad 6 Auto wide'src ='/ photos / listings / ad-6-auto-wide.jpg'>
 < img title ='Ad 6 Auto wide'alt ='Ad 6 Auto wide'src ='/ photos / listings / ad-6-auto-wide1.jpg'>
< img title ='Ad 6 Auto wide'alt ='Ad 6 Auto wide'src ='/ photos / listings / ad-6-auto-wide2.jpg'>
< img title ='广告6自动广告'alt ='广告6自动广播'src ='/ photos / listings / ad-6-auto-wide3.jpg'>
< img title ='Ad 6 Auto宽'alt ='Ad 6 A. uto wide'src ='/ photos / listings / ad-6-auto-wide4.jpg'>
]< / script>< / li>

 这是Javascript



$ ('.slider')。each(function(){
 var $ this = $(this);

 $ this.cycle({
幻灯片:'> img',
同步:true,
 progressive:function(){&# xD;
 var slides = $('。other-slides',$ this).html();
 return $ .parseJSON(slides);
 },
 speed:1500,
 timeout:4000,
 loader:true
});&#xD ;
}); 代码>
&#的xD;
 答案 0 :(得分:0)
你几乎就在那里。如果你查看cycle2网站上的progressive example,它会注意到脚本标记需要包含要加载的幻灯片的JSON数组。每个单独的幻灯片都需要用双引号括起来,并用逗号分隔幻灯片。
这里是渐进幻灯片的更新JSON:
<script class="other-slides" type="text/cycle">
[
"<img title='Ad 6 Auto wide' alt='Ad 6 Auto wide' src='/photos/listings/ad-6-auto-wide.jpg'>",
"<img title='Ad 6 Auto wide' alt='Ad 6 Auto wide' src='/photos/listings/ad-6-auto-wide1.jpg'>",
"<img title='Ad 6 Auto wide' alt='Ad 6 Auto wide' src='/photos/listings/ad-6-auto-wide2.jpg'>",
"<img title='Ad 6 Auto wide' alt='Ad 6 Auto wide' src='/photos/listings/ad-6-auto-wide3.jpg'>",
"<img title='Ad 6 Auto wide' alt='Ad 6 Auto wide' src='/photos/listings/ad-6-auto-wide4.jpg'>"
]
</script>
这里是working fiddle。