我正在尝试创建一个无限循环,通过 div 并在其他 div 中显示图像和一些描述文本,所以基本上它是一个画廊。
<div class="gallery">
<div class="header">gallery</div>
<div class="gimages"></div>
<div class="ggallery">
<div class="gitem" id="0"><div class="imgtext"><div>text</div></div><img src="images/gallery/1.jpg" border="0" /></div>
<div class="gitem" id="1"><div class="imgtext"><div>text</div></div><img src="images/gallery/2.jpg" border="0" /></div>
<div class="gitem" id="2"><div class="imgtext"><div>text</div></div><img src="images/gallery/3.jpg" border="0" /></div>
<div class="gitem" id="3"><div class="imgtext"><div>text</div></div><img src="images/gallery/4.jpg" border="0" /></div>
<div class="gitem" id="4"><div class="imgtext"><div>text</div></div><img src="images/gallery/5.jpg" border="0" /></div>
<div class="gitem" id="5"><div class="imgtext"><div>text</div></div><img src="images/gallery/6.jpg" border="0" /></div>
<div class="gitem" id="6"><div class="imgtext"><div>text</div></div><img src="images/gallery/7.jpg" border="0" /></div>
<div class="gitem" id="7"><div class="imgtext"><div>text</div></div><img src="images/gallery/8.jpg" border="0" /></div>
<div class="gitem" id="8"><div class="imgtext"><div>text</div></div><img src="images/gallery/9.jpg" border="0" /></div>
<div class="gitem" id="9"><div class="imgtext"><div>text</div></div><img src="images/gallery/10.jpg" border="0" /></div>
<div class="gitem" id="10"><div class="imgtext"><div>text</div></div><img src="images/gallery/11.jpg" border="0" /></div>
<div class="gitem" id="11"><div class="imgtext"><div>text</div></div><img src="images/gallery/12.jpg" border="0" /></div>
</div>
</div>
div ggallery 是 display:none,我从这里获取数据以放置在 div gimages 中。问题是它只会显示最后一张图像,除非我在每次迭代之间发出警报。这是脚本:
$(document).ready(function(){
var refreshId = setInterval( function(){
$('.gallery .ggallery .gitem').each(function(index){
$('.gallery .gimages').html($(this).html());
if(index==11){
index = 0;
}
});
}, 5000);
});
我究竟做错了什么?