如何根据随机幻灯片编号显示幻灯片?(How to show slide based on random slide number?)

编程入门 行业动态 更新时间:2024-10-27 12:31:25
如何根据随机幻灯片编号显示幻灯片?(How to show slide based on random slide number?) $("#btnOner").click(function(){ var min = 1; var max = 10; // and the formula is: for(var i=0;i<10;i++){ setTimeout(function(){ var random = Math.floor(Math.random() * (max - min + 1)) + min; $(".part3 ul li img#"+random).animate({opacity: 1}, 3000); $(".part3 ul li img#"+random).animate({opacity: 0.5}, 3000); },3000); } });

嗨,我有10张图片有不透明度,参数是0.5。 我想创建随机数,哪个图像有这个数字,它的不透明度将为1.然后在3秒后再次0.5并随机另一个数字并继续10次。 当我像这样使用一些图像一起显示时,我想1比1

请原谅我糟糕的英语, 谢谢你的建议

$("#btnOner").click(function(){ var min = 1; var max = 10; // and the formula is: for(var i=0;i<10;i++){ setTimeout(function(){ var random = Math.floor(Math.random() * (max - min + 1)) + min; $(".part3 ul li img#"+random).animate({opacity: 1}, 3000); $(".part3 ul li img#"+random).animate({opacity: 0.5}, 3000); },3000); } });

Hi, i have 10 pictures which have opacity, parameter is 0.5 . I would like to create random number and which image has this number, its opacity will be 1. Then after 3 second again 0.5 and random another number and continue to 10 times. When i use like this some images show together, i want to 1 by 1

Excuse my bad english, Thanks in advice

最满意答案

我想你想要这样的东西:

$("#btnOner").click(function(){ var min = 1; var max = 10; var i = min; var timer = setInterval(function(){ i++; var random = Math.floor(Math.random() * (max - min + 1)) + min; $(".part3 ul li img#"+random).animate({opacity: 1}, 3000); $(".part3 ul li img#"+random).animate({opacity: 0.5}, 3000); if (i > max) clearInterval(timer); },3000); });

I think you want something like this:

$("#btnOner").click(function(){ var min = 1; var max = 10; var i = min; var timer = setInterval(function(){ i++; var random = Math.floor(Math.random() * (max - min + 1)) + min; $(".part3 ul li img#"+random).animate({opacity: 1}, 3000); $(".part3 ul li img#"+random).animate({opacity: 0.5}, 3000); if (i > max) clearInterval(timer); },3000); });

更多推荐

本文发布于:2023-08-04 23:47:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1423164.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:幻灯片   编号   show   slide   random

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!