【问题标题】:jQuery Rotator Is Alphabetical, how can I make it randomized on my homepage?jQuery Rotator 是按字母顺序排列的,我怎样才能让它在我的主页上随机化?
【发布时间】:2012-06-19 18:16:18
【问题描述】:

如何让图像在我的旋转器上随机排列?以下是我正在开发的网站的链接,主页上的旋转器目前按字母顺序显示,我希望它是随机的。

http://www.greatrestaurantsmagazine.com/

【问题讨论】:

  • 如果您能提供帮助,请详细解释,因为我是脚本新手

标签: javascript html css rotator


【解决方案1】:

您可以执行一些操作,例如将列表移动到文档片段,然后使用随机发生器将它们一一添加,同时检查它尝试添加的项目是否尚未添加。

【讨论】:

  • 嗯?我是初学者,不知道从哪里开始回答???如何 ?在哪里 ?谢谢,但我不知道该怎么做
【解决方案2】:

打开您的 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
});

【讨论】:

  • Stack Overflow 不是交互式调试会话。
猜你喜欢
  • 1970-01-01
  • 2020-08-04
  • 2020-03-24
  • 2019-10-23
  • 2021-07-09
  • 2023-04-05
  • 2021-05-27
  • 2022-11-18
  • 1970-01-01
相关资源
最近更新 更多