【发布时间】:2012-06-19 18:16:18
【问题描述】:
如何让图像在我的旋转器上随机排列?以下是我正在开发的网站的链接,主页上的旋转器目前按字母顺序显示,我希望它是随机的。
【问题讨论】:
-
如果您能提供帮助,请详细解释,因为我是脚本新手
标签: javascript html css rotator
如何让图像在我的旋转器上随机排列?以下是我正在开发的网站的链接,主页上的旋转器目前按字母顺序显示,我希望它是随机的。
【问题讨论】:
标签: javascript html css rotator
您可以执行一些操作,例如将列表移动到文档片段,然后使用随机发生器将它们一一添加,同时检查它尝试添加的项目是否尚未添加。
【讨论】:
打开您的 dissolve.js 并进行以下更改。
这里的关键是随机化你的下一张图片,显然是下面的代码:
可以下载小demohere
确保您遵循代码中的these 说明
//Un-comment the 3 lines below to get the images in random order
var sibs = current.siblings();
var rndNum = Math.floor(Math.random() * sibs.length );
var next = $( sibs[ rndNum ] );
And then below your document ready section will look like:
$(document).ready(function() {
//Load the slideshow
$('div.rotator ul').shuffle();
theRotator();
$('div.rotator').fadeIn(1000);
$('div.rotator ul li').fadeIn(1000); // tweek for IE
});
【讨论】: