jquery图像幻灯片随机显示图像
我正在使用链接中的幻灯片放映:
http://www.alohatechsupport .net/webdesignmaui/maui-web-site-design/easy_jquery_auto_image_rotator 。 我需要第一张图像也是随机的。 我已经为所有像“rand”这样的李上了同一堂课。
var curr=$('div.rotator ul li.rand');
var rc= Math.floor(Math.random() * curr.length);
var current=$(curr[rc]);
然后但我坚持下一步该做什么..请帮助!
I am using a slide show from the link :
http://www.alohatechsupport.net/webdesignmaui/maui-web-site-design/easy_jquery_auto_image_rotator .
I need the first image to be also a random one.
I had given a same class for all the li like 'rand'.Then
var curr=$('div.rotator ul li.rand');
var rc= Math.floor(Math.random() * curr.length);
var current=$(curr[rc]);
But i am stuck with what to do next..plz help!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用 James Padolsey 提供的这个很棒的 JQuery shuffle 插件随机化 LI 元素的顺序。
我最近在一个项目中使用了它,它非常适合我的需求。
另外,它的源代码非常容易阅读(因此更容易理解)。
http://james.padolsey.com/javascript/shuffling-the-dom/
要在幻灯片上下文中使用此功能,您可以使用 Mark Alsup 的 JQuery Cycle 插件。首先随机播放 dom,然后运行幻灯片:
You can randomize the order of your LI elements using this awesome JQuery shuffle plugin by James Padolsey.
I have used it on a project recently and it worked very well for my needs.
Plus, the source of it is very easy to read (therefore easier to understand).
http://james.padolsey.com/javascript/shuffling-the-dom/
To use this in the context of a slideshow, you could use JQuery Cycle plugin by Mark Alsup. Shuffle the dom first, then run the slideshow:
这是另一个具有相同功能的 jQuery 插件:
http://yelotofu.com/ labs/jquery/snippets/shuffle/demo.html
关闭您提供的演示,您可以在此处下载
http://www.alohatechsupport.net/downloads/image-rotator.zip
确保遵循代码中的这些说明
,然后您的文档就绪部分将如下所示:
Here is another jQuery plugin that does the same ting:
http://yelotofu.com/labs/jquery/snippets/shuffle/demo.html
Going off the demo that you gave that you can download here
http://www.alohatechsupport.net/downloads/image-rotator.zip
Make sure you follow these intstructions in the code
And then below your document ready section will look like:
您用于幻灯片放映的代码太多了。这可以做得更简单。看看这个带有随机图像的幻灯片示例:http://jsbin.com/iledo3/3
这里粘贴代码供参考:
The code you have used for your slideshow is too much. this can be done much simpler. Have a look a this example of a slideshow with random images: http://jsbin.com/iledo3/3
The code pasted here for reference: