我怎么能显示与Twitter的引导旋转木马随机的一组幻灯片的?(How can I display

2019-10-28 09:25发布

如何创建幻灯片的数组,然后只随机显示一定数量的人?

例如,如果我建立一个这样的数组:

var slides = [];
slides[0] = '<div class="item"><img alt="" src="/Slides/gallery.jpg"></div>';
slides[1] = '<div class="item"><img alt="" src="/Slides/item1.jpg"></div>';
slides[2] = '<div class="item"><img alt="" src="/Slides/forums.jpg"></div>';
slides[3] = '<div class="item"><img alt="" src="/Slides/featured.jpg"></div>';
slides[4] = '<div class="item"><img alt="" src="/Slides/sale.jpg"></div>';
slides[5] = '<div class="item"><img alt="" src="/Slides/discount.jpg"></div>';
slides[6] = '<div class="item"><img alt="" src="/Slides/gallery.jpg"></div>';
slides[7] = '<div class="item"><img alt="" src="/Slides/a.jpg"></div>';
slides[8] = '<div class="item"><img alt="" src="/Slides/b.jpg"></div>';
slides[9] = '<div class="item"><img alt="" src="/Slides/c.jpg"></div>';
slides[10] = '<div class="item"><img alt="" src="/Slides/d.jpg"></div>';

我怎么能随意选择10的5,然后将其输出到Twitter的引导旋转木马?

<div id="myCarousel" class="carousel">
    [Items go here, first one needs to get the class 'active']
</div>
文章来源: How can I display a random set of slides with the Twitter Bootstrap carousel?