是否可以使此代码随机化幻灯片的图像
这里我有一些代码,这是我的幻灯片,我想知道你是否可以随机化图像,这样当你刷新页面时它就不会在同一张图像上开始。
请向我提供有用的信息,如果您愿意,请随时向我展示。
谢谢大家! :)
<html>
<head>
<title>JQuery Cycle Plugin Sample</title>
<link rel="stylesheet" type="text/css" media="screen" href="../screen.css" />
<script type="text/javascript" src="../js2/jquery-1.3.js"></script>
<script type="text/javascript" src="../js2/jquery.cycle.all.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#myslides').cycle({
fx: 'fade',
speed: 2000,
timeout: 2000
});
});
</script>
</head>
<body>
<div id="myslides">
<img src="../images/capitol.jpg" />
<img src="../images/flowers.jpg" />
<img src="../images/countryscene.jpg" />
<img src="../images/heartkush.jpg"/>
</div>
</body>
</html>
Here i have some code which is my slideshow and what i am wondering is whether you can randomize the images so it doesn't start on the same image when you refresh the page.
Please provide me with useful info and if you wish to show me feel free.
THNAKS GUYS! :)
<html>
<head>
<title>JQuery Cycle Plugin Sample</title>
<link rel="stylesheet" type="text/css" media="screen" href="../screen.css" />
<script type="text/javascript" src="../js2/jquery-1.3.js"></script>
<script type="text/javascript" src="../js2/jquery.cycle.all.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#myslides').cycle({
fx: 'fade',
speed: 2000,
timeout: 2000
});
});
</script>
</head>
<body>
<div id="myslides">
<img src="../images/capitol.jpg" />
<img src="../images/flowers.jpg" />
<img src="../images/countryscene.jpg" />
<img src="../images/heartkush.jpg"/>
</div>
</body>
</html>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
例如,您可能希望将图像网址保存在变量中(或者从
div
中检索它们,然后清除div
)(或者甚至更好 - 进行一些预加载)。然后进行随机排序
,然后动态添加图像
,然后进行幻灯片放映。最终的脚本可能如下所示:
You may want to hold image urls in a variable (or retrieve them from your
div
and clear thediv
afterwards), say(or even better - do some preloading). Then do a random sort
then dynamically add images
and then do the slideshow. The final script may look like this:
这只是 jQuery 循环拥有的众多选项之一。
将
random: true
添加到选项中,如下所示:This is just one of the many options that jQuery cycle has.
Add
random: true
to the options like so: