[英]jQuery Rotator Is Alphabetical, how can I make it randomized on my homepage?
How can I get images to be random on my rotator? 如何在旋转器上获得随机图像? Below is a link to the site I am working on and the rotator on the homepage is currently displaying alphabetically and I would like it random.
以下是指向我正在工作的网站的链接,并且主页上的旋转器当前按字母顺序显示,我希望随机显示。
http://www.greatrestaurantsmagazine.com/ http://www.greatrestaurantsmagazine.com/
您可以执行以下操作,例如将列表移至文档片段,然后使用随机化器将其一一添加回去,同时检查尚未尝试添加的项目。
Open up your disolve.js and make the below changes. 打开您的disolve.js并进行以下更改。
key here is randomizing your next image , apparently the code below : 这里的关键是随机化您的下一张图像,显然是下面的代码:
You can download a small demo here 您可以在此处下载一个小演示
Make sure you follow these intstructions in the code 确保遵循代码中的这些说明
//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
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.