简体   繁体   中英

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/

您可以执行以下操作,例如将列表移至文档片段,然后使用随机化器将其一一添加回去,同时检查尚未尝试添加的项目。

Open up your disolve.js and make the below changes.

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
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM