如何根据随机幻灯片编号显示幻灯片?(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); });更多推荐
发布评论